[llvm] [LV] Use frozen start value for FindLastIV if needed. (PR #132691)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 31 14:27:13 PDT 2025
================
@@ -9866,14 +9869,31 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
// also modeled in VPlan.
VPInstruction *FinalReductionResult;
VPBuilder::InsertPointGuard Guard(Builder);
- Builder.setInsertPoint(MiddleVPBB, IP);
if (RecurrenceDescriptor::isFindLastIVRecurrenceKind(
RdxDesc.getRecurrenceKind())) {
VPValue *Start = PhiR->getStartValue();
+ if (!isGuaranteedNotToBeUndefOrPoison(
+ PhiR->getStartValue()->getLiveInIRValue())) {
+ Builder.setInsertPoint(cast<VPBasicBlock>(Plan->getEntry()));
+ Start = Builder.createNaryOp(Instruction::Freeze, {Start}, {}, "fr");
+ }
+ Builder.setInsertPoint(MiddleVPBB, IP);
FinalReductionResult =
Builder.createNaryOp(VPInstruction::ComputeFindLastIVResult,
{PhiR, Start, NewExitingVPV}, ExitDL);
+ // Update all users outside the vector region.
+ for (VPUser *U : to_vector(OrigExitingVPV->users())) {
+ auto *R = cast<VPRecipeBase>(U);
+ if (R->getParent() && R->getParent()->getParent())
----------------
fhahn wrote:
Updated to check that the parent's region is the vector loop region, thanks
https://github.com/llvm/llvm-project/pull/132691
More information about the llvm-commits
mailing list