[llvm] AMDGPU: fix isSafeToSink expecting exactly one predecessor (PR #89224)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 08:09:38 PDT 2024


================
@@ -214,13 +214,12 @@ bool SIInstrInfo::isSafeToSink(MachineInstr &MI,
       // 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.
-        SmallVector<MachineBasicBlock *, 1> ExitBlocks;
-        FromCycle->getExitBlocks(ExitBlocks);
-        assert(ExitBlocks.size() == 1);
-        assert(ExitBlocks[0]->getSinglePredecessor());
+        SmallVector<MachineBasicBlock *, 1> ExitingBlocks;
+        FromCycle->getExitingBlocks(ExitingBlocks);
+        assert(ExitingBlocks.size() == 1);
 
         // FromCycle has divergent exit condition.
-        if (hasDivergentBranch(ExitBlocks[0]->getSinglePredecessor())) {
+        if (hasDivergentBranch(ExitingBlocks[0])) {
----------------
jayfoad wrote:

Please return false if _any_ exiting block has a divergent branch

https://github.com/llvm/llvm-project/pull/89224


More information about the llvm-commits mailing list