@@ -1712,16 +1712,20 @@ void VPFirstOrderRecurrencePHIRecipe::print(raw_ostream &O, const Twine &Indent,
1712
1712
#endif
1713
1713
1714
1714
void VPReductionPHIRecipe::execute (VPTransformState &State) {
1715
- PHINode *PN = cast<PHINode>(getUnderlyingValue ());
1716
1715
auto &Builder = State.Builder ;
1717
1716
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
+
1718
1722
// In order to support recurrences we need to be able to vectorize Phi nodes.
1719
1723
// Phi nodes have cycles, so we need to vectorize them in two stages. This is
1720
1724
// stage #1: We create a new vector PHI node with no incoming edges. We'll use
1721
1725
// this value when we vectorize all of the instructions that use the PHI.
1722
1726
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 );
1725
1729
1726
1730
BasicBlock *HeaderBB = State.CFG .PrevBB ;
1727
1731
assert (State.CurrentVectorLoop ->getHeader () == HeaderBB &&
@@ -1735,11 +1739,6 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
1735
1739
1736
1740
BasicBlock *VectorPH = State.CFG .getPreheaderBBFor (this );
1737
1741
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
-
1743
1742
Value *Iden = nullptr ;
1744
1743
RecurKind RK = RdxDesc.getRecurrenceKind ();
1745
1744
if (RecurrenceDescriptor::isMinMaxRecurrenceKind (RK) ||
0 commit comments