@@ -647,15 +647,14 @@ Value *VPInstruction::generate(VPTransformState &State) {
647
647
// FIXME: The cross-recipe dependency on VPReductionPHIRecipe is temporary
648
648
// and will be removed by breaking up the recipe further.
649
649
auto *PhiR = cast<VPReductionPHIRecipe>(getOperand (0 ));
650
- auto *OrigPhi = cast<PHINode>(PhiR->getUnderlyingValue ());
651
650
// Get its reduction variable descriptor.
652
651
const RecurrenceDescriptor &RdxDesc = PhiR->getRecurrenceDescriptor ();
653
652
654
653
RecurKind RK = RdxDesc.getRecurrenceKind ();
655
654
assert (!RecurrenceDescriptor::isFindLastIVRecurrenceKind (RK) &&
656
655
" should be handled by ComputeFindLastIVResult" );
657
656
658
- Type *PhiTy = OrigPhi-> getType ( );
657
+ Type *ResultTy = State. TypeAnalysis . inferScalarType ( this );
659
658
// The recipe's operands are the reduction phi, followed by one operand for
660
659
// each part of the reduction.
661
660
unsigned UF = getNumOperands () - 1 ;
@@ -671,7 +670,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
671
670
// then extend the loop exit value to enable InstCombine to evaluate the
672
671
// entire expression in the smaller type.
673
672
// TODO: Handle this in truncateToMinBW.
674
- if (State.VF .isVector () && PhiTy != RdxDesc.getRecurrenceType ()) {
673
+ if (State.VF .isVector () && ResultTy != RdxDesc.getRecurrenceType ()) {
675
674
Type *RdxVecTy = VectorType::get (RdxDesc.getRecurrenceType (), State.VF );
676
675
for (unsigned Part = 0 ; Part < UF; ++Part)
677
676
RdxParts[Part] = Builder.CreateTrunc (RdxParts[Part], RdxVecTy);
@@ -703,10 +702,10 @@ Value *VPInstruction::generate(VPTransformState &State) {
703
702
704
703
// If the reduction can be performed in a smaller type, we need to extend
705
704
// the reduction to the wider type before we branch to the original loop.
706
- if (PhiTy != RdxDesc.getRecurrenceType ())
705
+ if (ResultTy != RdxDesc.getRecurrenceType ())
707
706
ReducedPartRdx = RdxDesc.isSigned ()
708
- ? Builder.CreateSExt (ReducedPartRdx, PhiTy )
709
- : Builder.CreateZExt (ReducedPartRdx, PhiTy );
707
+ ? Builder.CreateSExt (ReducedPartRdx, ResultTy )
708
+ : Builder.CreateZExt (ReducedPartRdx, ResultTy );
710
709
}
711
710
712
711
return ReducedPartRdx;
0 commit comments