aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorPetar Avramovic <Petar.Avramovic@amd.com>2023-10-04 13:58:47 +0200
committerPetar Avramovic <Petar.Avramovic@amd.com>2023-10-06 15:00:08 +0200
commit2fa7d652d02ae5da0d32d63c4258705eadab1576 (patch)
treee4357c0b510667a4da94b54f05a1f3389af865db /llvm/lib/CodeGen/MachineSink.cpp
parent2d7fe90a3eb8b31bc02ee4407b3e74336ac729fc (diff)
downloadllvm-2fa7d652d02ae5da0d32d63c4258705eadab1576.zip
llvm-2fa7d652d02ae5da0d32d63c4258705eadab1576.tar.gz
llvm-2fa7d652d02ae5da0d32d63c4258705eadab1576.tar.bz2
AMDGPU: Fix temporal divergence introduced by machine-sink (#67456)
Temporal divergence that was present in input or introduced in IR transforms, like code-sinking or LICM, is handled in SIFixSGPRCopies by changing sgpr source instr to vgpr instr. After 5b657f5, that moved LICM after AMDGPUCodeGenPrepare, machine-sinking can introduce temporal divergence by sinking instructions outside of the cycle. Add isSafeToSink callback in TargetInstrInfo.
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index 14de333..2d9ff33 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -735,6 +735,7 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) {
MadeChange = true;
++NumSplit;
+ CI->splitCriticalEdge(Pair.first, Pair.second, NewSucc);
} else
LLVM_DEBUG(dbgs() << " *** Not legal to break critical edge\n");
}
@@ -1263,6 +1264,9 @@ MachineSinking::FindSuccToSinkTo(MachineInstr &MI, MachineBasicBlock *MBB,
if (SuccToSinkTo && SuccToSinkTo->isInlineAsmBrIndirectTarget())
return nullptr;
+ if (SuccToSinkTo && !TII->isSafeToSink(MI, SuccToSinkTo, CI))
+ return nullptr;
+
return SuccToSinkTo;
}