@@ -8844,37 +8844,28 @@ static VPValue *addResumeValuesForInduction(VPHeaderPHIRecipe *PhiR,
8844
8844
VPBuilder &ScalarPHBuilder,
8845
8845
VPTypeAnalysis &TypeInfo,
8846
8846
VPValue *VectorTC) {
8847
- PHINode *OrigPhi;
8848
- const InductionDescriptor *ID;
8849
- VPValue *Start = PhiR->getStartValue ();
8850
- VPValue *Step;
8851
- Type *ScalarTy;
8847
+ auto *WideIV = dyn_cast<VPWidenInductionRecipe>(PhiR);
8848
+ if (!WideIV)
8849
+ return nullptr ;
8850
+
8851
+ VPValue *Start = WideIV->getStartValue ();
8852
+ VPValue *Step = WideIV->getStepValue ();
8853
+ const InductionDescriptor &ID = WideIV->getInductionDescriptor ();
8854
+ Type *ScalarTy = TypeInfo.inferScalarType (WideIV);
8852
8855
bool IsCanonical = false ;
8853
8856
if (auto *WideIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(PhiR)) {
8854
8857
// Truncated wide inductions resume from the last lane of their vector value
8855
8858
// in the last vector iteration.
8856
- if (WideIV-> getTruncInst ( ))
8859
+ if (ScalarTy != TypeInfo. inferScalarType (Step ))
8857
8860
return nullptr ;
8858
- OrigPhi = cast<PHINode>(WideIV->getUnderlyingValue ());
8859
- ID = &WideIV->getInductionDescriptor ();
8860
- Step = WideIV->getStepValue ();
8861
- ScalarTy = WideIV->getScalarType ();
8862
8861
IsCanonical = WideIV->isCanonical ();
8863
- } else if (auto *WideIV = dyn_cast<VPWidenPointerInductionRecipe>(PhiR)) {
8864
- OrigPhi = cast<PHINode>(WideIV->getUnderlyingValue ());
8865
- ID = &WideIV->getInductionDescriptor ();
8866
- Step = WideIV->getOperand (1 );
8867
- ScalarTy = Start->getLiveInIRValue ()->getType ();
8868
- } else {
8869
- return nullptr ;
8870
8862
}
8871
8863
8872
8864
VPValue *EndValue = VectorTC;
8873
8865
if (!IsCanonical) {
8874
8866
EndValue = VectorPHBuilder.createDerivedIV (
8875
- ID->getKind (),
8876
- dyn_cast_or_null<FPMathOperator>(ID->getInductionBinOp ()), Start,
8877
- VectorTC, Step);
8867
+ ID.getKind (), dyn_cast_or_null<FPMathOperator>(ID.getInductionBinOp ()),
8868
+ Start, VectorTC, Step);
8878
8869
}
8879
8870
8880
8871
// EndValue is based on the vector trip count (which has the same type as the
@@ -8886,7 +8877,7 @@ static VPValue *addResumeValuesForInduction(VPHeaderPHIRecipe *PhiR,
8886
8877
8887
8878
auto *ResumePhiRecipe =
8888
8879
ScalarPHBuilder.createNaryOp (VPInstruction::ResumePhi, {EndValue, Start},
8889
- OrigPhi ->getDebugLoc (), " bc.resume.val" );
8880
+ WideIV ->getDebugLoc (), " bc.resume.val" );
8890
8881
return ResumePhiRecipe;
8891
8882
}
8892
8883
0 commit comments