[llvm] 732ebf8 - [VPlan] Address post-commit comments for f68848015f62.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 14 02:49:18 PDT 2025
Author: Florian Hahn
Date: 2025-06-14T10:44:20+01:00
New Revision: 732ebf803b80a8a3fc3aaaceb600cebdf659118e
URL: https://github.com/llvm/llvm-project/commit/732ebf803b80a8a3fc3aaaceb600cebdf659118e
DIFF: https://github.com/llvm/llvm-project/commit/732ebf803b80a8a3fc3aaaceb600cebdf659118e.diff
LOG: [VPlan] Address post-commit comments for f68848015f62.
Assign sentinel value to named variable to clarify naming and update
comments.
Addresses post-commit comments from
https://github.com/llvm/llvm-project/pull/142291.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 93f53996425d3..7c006ae326ecb 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -7263,14 +7263,13 @@ static void fixReductionScalarResumeWhenVectorizingEpilog(
} else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind(
RdxDesc.getRecurrenceKind())) {
Value *StartV = getStartValueFromReductionResult(EpiRedResult);
+ Value *SentinelV = EpiRedResult->getOperand(2)->getLiveInIRValue();
using namespace llvm::PatternMatch;
Value *Cmp, *OrigResumeV, *CmpOp;
bool IsExpectedPattern =
match(MainResumeValue,
- m_Select(
- m_OneUse(m_Value(Cmp)),
- m_Specific(EpiRedResult->getOperand(2)->getLiveInIRValue()),
- m_Value(OrigResumeV))) &&
+ m_Select(m_OneUse(m_Value(Cmp)), m_Specific(SentinelV),
+ m_Value(OrigResumeV))) &&
(match(Cmp, m_SpecificICmp(ICmpInst::ICMP_EQ, m_Specific(OrigResumeV),
m_Value(CmpOp))) &&
((CmpOp == StartV && isGuaranteedNotToBeUndefOrPoison(CmpOp))));
@@ -9224,11 +9223,10 @@ void LoopVectorizationPlanner::adjustRecipesForReductions(
if (RecurrenceDescriptor::isFindLastIVRecurrenceKind(
RdxDesc.getRecurrenceKind())) {
VPValue *Start = PhiR->getStartValue();
- FinalReductionResult = Builder.createNaryOp(
- VPInstruction::ComputeFindLastIVResult,
- {PhiR, Start, Plan->getOrAddLiveIn(RdxDesc.getSentinelValue()),
- NewExitingVPV},
- ExitDL);
+ VPValue *Sentinel = Plan->getOrAddLiveIn(RdxDesc.getSentinelValue());
+ FinalReductionResult =
+ Builder.createNaryOp(VPInstruction::ComputeFindLastIVResult,
+ {PhiR, Start, Sentinel, NewExitingVPV}, ExitDL);
} else if (RecurrenceDescriptor::isAnyOfRecurrenceKind(
RdxDesc.getRecurrenceKind())) {
VPValue *Start = PhiR->getStartValue();
@@ -9816,8 +9814,8 @@ preparePlanForEpilogueVectorLoop(VPlan &Plan, Loop *L,
BasicBlock *ResumeBB = cast<Instruction>(ResumeV)->getParent();
IRBuilder<> Builder(ResumeBB, ResumeBB->getFirstNonPHIIt());
Value *Cmp = Builder.CreateICmpEQ(ResumeV, ToFrozen[StartV]);
- ResumeV = Builder.CreateSelect(
- Cmp, RdxResult->getOperand(2)->getLiveInIRValue(), ResumeV);
+ Value *Sentinel = RdxResult->getOperand(2)->getLiveInIRValue();
+ ResumeV = Builder.CreateSelect(Cmp, Sentinel, ResumeV);
} else {
VPValue *StartVal = Plan.getOrAddLiveIn(ResumeV);
auto *PhiR = dyn_cast<VPReductionPHIRecipe>(&R);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index d59cec892d405..c64bda167b854 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -643,8 +643,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
assert(!PhiR->isInLoop() &&
"In-loop FindLastIV reduction is not supported yet");
- // The recipe's operands are the reduction phi, followed by one operand for
- // each part of the reduction.
+ // The recipe's operands are the reduction phi, the start value, the
+ // sentinel value, followed by one operand for each part of the reduction.
unsigned UF = getNumOperands() - 3;
Value *ReducedPartRdx = State.get(getOperand(3));
for (unsigned Part = 1; Part < UF; ++Part) {
@@ -652,9 +652,9 @@ Value *VPInstruction::generate(VPTransformState &State) {
State.get(getOperand(3 + Part)));
}
- return createFindLastIVReduction(Builder, ReducedPartRdx,
- State.get(getOperand(1), true),
- getOperand(2)->getLiveInIRValue());
+ Value *Start = State.get(getOperand(1), true);
+ Value *Sentinel = getOperand(2)->getLiveInIRValue();
+ return createFindLastIVReduction(Builder, ReducedPartRdx, Start, Sentinel);
}
case VPInstruction::ComputeReductionResult: {
// FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary
More information about the llvm-commits
mailing list