Skip to content

Commit

Permalink
R600/SI: fix inserting waits for unordered defines
Browse files Browse the repository at this point in the history
Signed-off-by: Christian König <[email protected]>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@176342 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ChristianKoenigAMD committed Mar 1, 2013
1 parent 4d9b7c2 commit 9ff8dc8
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions lib/Target/R600/SIInsertWaits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ class SIInsertWaits : public MachineFunctionPass {
MachineBasicBlock::iterator I,
const Counters &Counts);

/// \brief Do we need def2def checks?
bool unorderedDefines(MachineInstr &MI);

/// \brief Resolve all operand dependencies to counter requirements
Counters handleOperands(MachineInstr &MI);

Expand Down Expand Up @@ -125,7 +128,7 @@ Counters SIInsertWaits::getHwCounts(MachineInstr &MI) {

// Only consider stores or EXP for EXP_CNT
Result.Named.EXP = !!(TSFlags & SIInstrFlags::EXP_CNT &&
(MI.getOpcode() == AMDGPU::EXP || !MI.getDesc().mayStore()));
(MI.getOpcode() == AMDGPU::EXP || MI.getDesc().mayStore()));

// LGKM may uses larger values
if (TSFlags & SIInstrFlags::LGKM_CNT) {
Expand Down Expand Up @@ -299,8 +302,21 @@ static void increaseCounters(Counters &Dst, const Counters &Src) {
Dst.Array[i] = std::max(Dst.Array[i], Src.Array[i]);
}

bool SIInsertWaits::unorderedDefines(MachineInstr &MI) {

uint64_t TSFlags = TII->get(MI.getOpcode()).TSFlags;
if (TSFlags & SIInstrFlags::LGKM_CNT)
return true;

if (TSFlags & SIInstrFlags::EXP_CNT)
return ExpInstrTypesSeen == 3;

return false;
}

Counters SIInsertWaits::handleOperands(MachineInstr &MI) {

bool UnorderedDefines = unorderedDefines(MI);
Counters Result = ZeroCounts;

// For each register affected by this
Expand All @@ -311,8 +327,11 @@ Counters SIInsertWaits::handleOperands(MachineInstr &MI) {
RegInterval Interval = getRegInterval(Op);
for (unsigned j = Interval.first; j < Interval.second; ++j) {

if (Op.isDef())
if (Op.isDef()) {
increaseCounters(Result, UsedRegs[j]);
if (UnorderedDefines)
increaseCounters(Result, DefinedRegs[j]);
}

if (Op.isUse())
increaseCounters(Result, DefinedRegs[j]);
Expand Down

0 comments on commit 9ff8dc8

Please sign in to comment.