[PATCH] D98888: [AMDGPU] SIOptimizeExecMaskingPreRA should check constant bus constraint when folds EXEC copy
Alexander via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 18 12:31:35 PDT 2021
alex-t created this revision.
alex-t added a reviewer: rampitec.
Herald added subscribers: kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, arsenm.
alex-t requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
Folding EXEC copy into it's single use may lead to constant bus constraint violation as it adds one more SGPR operand.
This change makes it validate the user instruction with the new SGPR operand and only fold it if it is legal.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98888
Files:
llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
Index: llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
+++ llvm/lib/Target/AMDGPU/SIOptimizeExecMaskingPreRA.cpp
@@ -416,15 +416,19 @@
continue;
Register SavedExec = I->getOperand(0).getReg();
- if (SavedExec.isVirtual() && MRI->hasOneNonDBGUse(SavedExec) &&
- MRI->use_instr_nodbg_begin(SavedExec)->getParent() ==
- I->getParent()) {
- LLVM_DEBUG(dbgs() << "Redundant EXEC COPY: " << *I << '\n');
- LIS->RemoveMachineInstrFromMaps(*I);
- I->eraseFromParent();
- MRI->replaceRegWith(SavedExec, ExecReg);
- LIS->removeInterval(SavedExec);
- Changed = true;
+ if (SavedExec.isVirtual() && MRI->hasOneNonDBGUse(SavedExec)) {
+ MachineInstr *SingleExecUser = &*MRI->use_instr_nodbg_begin(SavedExec);
+ int idx = SingleExecUser->findRegisterUseOperandIdx(SavedExec);
+ assert(idx != -1);
+ if (SingleExecUser->getParent() == I->getParent() &&
+ TII->isOperandLegal(*SingleExecUser, idx, &I->getOperand(1))) {
+ LLVM_DEBUG(dbgs() << "Redundant EXEC COPY: " << *I << '\n');
+ LIS->RemoveMachineInstrFromMaps(*I);
+ I->eraseFromParent();
+ MRI->replaceRegWith(SavedExec, ExecReg);
+ LIS->removeInterval(SavedExec);
+ Changed = true;
+ }
}
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98888.331656.patch
Type: text/x-patch
Size: 1483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210318/69ee4cbe/attachment.bin>
More information about the llvm-commits
mailing list