[llvm] AMDGPU: fix isSafeToSink expecting exactly one predecessor (PR #89224)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 07:06:32 PDT 2024
================
@@ -213,17 +213,20 @@ bool SIInstrInfo::isSafeToSink(MachineInstr &MI,
// Check if there is a FromCycle that contains SgprDef's basic block but
// does not contain SuccToSinkTo and also has divergent exit condition.
while (FromCycle && !FromCycle->contains(ToCycle)) {
- // After structurize-cfg, there should be exactly one cycle exit.
+ // After structurize-cfg, there should be exactly one cycle exit. Also,
+ // cycle exit block should have exactly one predecessor, the cycle exit.
+ // Early-tailduplication can removed that block so we have to search for
+ // predecessor that is in cycle.
----------------
ruiling wrote:
The comment here is not useful anymore. The logic should work in general CFG. Meanwhile, I would like to see the code cleaner. Instead of getting exit blocks and check its predecessors. Let's just check against cycle exiting blocks.
```
FromCycle->getExitingBlocks(ExitingBlocks);
for (auto *Exiting : ExistingBlocks)
if (hasDivergentBranch(Exiting))
return false;
```
https://github.com/llvm/llvm-project/pull/89224
More information about the llvm-commits
mailing list