[llvm] [VPlan] Create header phi recipes after initial scalar optimizations. (PR #200920)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 9 01:54:12 PDT 2026
================
@@ -871,17 +884,20 @@ static bool tryToSinkOrHoistRecurrenceUsers(VPBasicBlock *HeaderVPBB,
Previous = PrevPhi->getBackedgeValue()->getDefiningRecipe();
}
- assert(Previous && "Previous must be a recipe");
- // Sink FOR users after Previous or hoist Previous before FOR users.
- if (!sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT) &&
- !hoistPreviousBeforeFORUsers(FOR, Previous, VPDT))
- return false;
+ VPBasicBlock *InsertBlock = FOR->getParent();
+ VPBasicBlock::iterator InsertPt = InsertBlock->getFirstNonPhi();
+ if (Previous) {
+ // Sink FOR users after Previous or hoist Previous before FOR users.
+ if (!sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT) &&
+ !hoistPreviousBeforeFORUsers(FOR, Previous, VPDT))
+ return false;
+ InsertBlock = Previous->getParent();
+ InsertPt = isa<VPHeaderPHIRecipe>(Previous)
+ ? InsertBlock->getFirstNonPhi()
+ : std::next(Previous->getIterator());
----------------
artagnon wrote:
```suggestion
if (Previous && !sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT) &&
!hoistPreviousBeforeFORUsers(FOR, Previous, VPDT))
return false;
InsertBlock = Previous ? Previous->getParent() : FOR->getParent();
InsertPt = isa_and_nonnull<VPHeaderPHIRecipe>(Previous)
? InsertBlock->getFirstNonPhi()
: std::next(Previous->getIterator());
```
.... and remove the conditional block?
https://github.com/llvm/llvm-project/pull/200920
More information about the llvm-commits
mailing list