[PATCH] D144123: [LV] Add setStartValue to VPWidenIntOrFPInductionRecipe
Michael Maitland via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 10:30:04 PST 2023
michaelmaitland created this revision.
michaelmaitland added reviewers: fhahn, nikolaypanchenko, reames.
Herald added subscribers: StephenFan, rogfer01, hiraditya.
Herald added a project: All.
michaelmaitland requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, vkmr.
Herald added a project: LLVM.
VPWidenIntOrFPInductionRecipe is casted to VPHeaderPHIRecipe even
though it is not a VPHeaderPHIRecipe. Then setStartValue is called
on the VPWidenIntOrFPInductionRecipe which was casted to a class
that it does not inherit from. This bug was not caught because
VPHeaderPHIRecipe::setStartValue has the same body that *should*
have existed in VPWidenIntOrFPInductionRecipe. This patch
casts to the correct Recipe type and calls the correct
setStartValue function.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144123
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -1061,6 +1061,9 @@
VPValue *getStartValue() { return getOperand(0); }
const VPValue *getStartValue() const { return getOperand(0); }
+ /// Sets the start value of the induction
+ void setStartValue(VPValue *V) { setOperand(0, V); }
+
/// Returns the step value of the induction.
VPValue *getStepValue() { return getOperand(1); }
const VPValue *getStepValue() const { return getOperand(1); }
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10467,7 +10467,10 @@
}
assert(ResumeV && "Must have a resume value");
VPValue *StartVal = BestEpiPlan.getOrAddExternalDef(ResumeV);
- cast<VPHeaderPHIRecipe>(&R)->setStartValue(StartVal);
+ if (auto *PhiR = dyn_cast<VPHeaderPHIRecipe>(&R))
+ PhiR->setStartValue(StartVal);
+ else if (auto *PhiR = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R))
+ PhiR->setStartValue(StartVal);
}
LVP.executePlan(EPI.EpilogueVF, EPI.EpilogueUF, BestEpiPlan, EpilogILV,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144123.497738.patch
Type: text/x-patch
Size: 1392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230215/4c1ca1ca/attachment.bin>
More information about the llvm-commits
mailing list