[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:23:00 PDT 2024
================
@@ -214,14 +214,14 @@ 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);
// FromCycle has divergent exit condition.
- if (hasDivergentBranch(ExitBlocks[0]->getSinglePredecessor())) {
- return false;
+ for (MachineBasicBlock *ExitingBlock : ExitingBlocks) {
+ if (hasDivergentBranch(ExitingBlock)) {
+ return false;
+ }
----------------
jayfoad wrote:
Nit: don't need braces around a single physical line.
https://github.com/llvm/llvm-project/pull/89224
More information about the llvm-commits
mailing list