Skip to content

Commit 6011d6b

Browse files
committed
[VPlan] Use start value of reduction phi to determine type (NFCI).
Instead of accessing the underlying original IR value, check the type of the start value from the recipe directly.
1 parent da76073 commit 6011d6b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,16 +1712,20 @@ void VPFirstOrderRecurrencePHIRecipe::print(raw_ostream &O, const Twine &Indent,
17121712
#endif
17131713

17141714
void VPReductionPHIRecipe::execute(VPTransformState &State) {
1715-
PHINode *PN = cast<PHINode>(getUnderlyingValue());
17161715
auto &Builder = State.Builder;
17171716

1717+
// Reductions do not have to start at zero. They can start with
1718+
// any loop invariant values.
1719+
VPValue *StartVPV = getStartValue();
1720+
Value *StartV = StartVPV->getLiveInIRValue();
1721+
17181722
// In order to support recurrences we need to be able to vectorize Phi nodes.
17191723
// Phi nodes have cycles, so we need to vectorize them in two stages. This is
17201724
// stage #1: We create a new vector PHI node with no incoming edges. We'll use
17211725
// this value when we vectorize all of the instructions that use the PHI.
17221726
bool ScalarPHI = State.VF.isScalar() || IsInLoop;
1723-
Type *VecTy =
1724-
ScalarPHI ? PN->getType() : VectorType::get(PN->getType(), State.VF);
1727+
Type *VecTy = ScalarPHI ? StartV->getType()
1728+
: VectorType::get(StartV->getType(), State.VF);
17251729

17261730
BasicBlock *HeaderBB = State.CFG.PrevBB;
17271731
assert(State.CurrentVectorLoop->getHeader() == HeaderBB &&
@@ -1735,11 +1739,6 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
17351739

17361740
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this);
17371741

1738-
// Reductions do not have to start at zero. They can start with
1739-
// any loop invariant values.
1740-
VPValue *StartVPV = getStartValue();
1741-
Value *StartV = StartVPV->getLiveInIRValue();
1742-
17431742
Value *Iden = nullptr;
17441743
RecurKind RK = RdxDesc.getRecurrenceKind();
17451744
if (RecurrenceDescriptor::isMinMaxRecurrenceKind(RK) ||

0 commit comments

Comments
 (0)