[llvm] AMDGPU: Fix temporal divergence introduced by machine-sink and performance regression introduced by D155343 (PR #67456)
Nicolai Hähnle via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 11:38:12 PDT 2023
================
@@ -171,6 +171,48 @@ bool SIInstrInfo::isIgnorableUse(const MachineOperand &MO) const {
isVALU(*MO.getParent()) && !resultDependsOnExec(*MO.getParent());
}
+bool SIInstrInfo::isSafeToSink(MachineInstr &MI,
+ MachineBasicBlock *SuccToSinkTo,
+ MachineCycleInfo *CI) const {
+ CI->clear();
+ CI->compute(*MI.getMF());
+ MachineRegisterInfo &MRI = MI.getMF()->getRegInfo();
+
+ // Check if sinking of MI would create temporal divergent use.
+ for (auto Op : MI.uses()) {
+ if (Op.isReg() && Op.getReg().isVirtual() &&
+ RI.isSGPRClass(MRI.getRegClass(Op.getReg()))) {
+ MachineInstr *SgprDef = MRI.getVRegDef(Op.getReg());
+
+ // SgprDef defined inside cycle
+ MachineCycle *FromCycle = CI->getCycle(SgprDef->getParent());
+ if (FromCycle == nullptr)
+ return true;
----------------
nhaehnle wrote:
Should be `continue` (also below) since this needs to look at all operands.
https://github.com/llvm/llvm-project/pull/67456
More information about the llvm-commits
mailing list