@@ -735,8 +735,13 @@ void VPWidenIntOrFpInductionRecipe::print(raw_ostream &O, const Twine &Indent,
735
735
#endif
736
736
737
737
bool VPWidenIntOrFpInductionRecipe::isCanonical () const {
738
+ // The step may be defined by a recipe in the preheader (e.g. if it requires
739
+ // SCEV expansion), but for the canonical induction the step is required to be
740
+ // 1, which is represented as live-in.
741
+ if (getStepValue ()->getDefiningRecipe ())
742
+ return false ;
743
+ auto *StepC = dyn_cast<ConstantInt>(getStepValue ()->getLiveInIRValue ());
738
744
auto *StartC = dyn_cast<ConstantInt>(getStartValue ()->getLiveInIRValue ());
739
- auto *StepC = dyn_cast<SCEVConstant>(getInductionDescriptor ().getStep ());
740
745
return StartC && StartC->isZero () && StepC && StepC->isOne ();
741
746
}
742
747
@@ -1091,20 +1096,22 @@ void VPCanonicalIVPHIRecipe::print(raw_ostream &O, const Twine &Indent,
1091
1096
}
1092
1097
#endif
1093
1098
1094
- bool VPCanonicalIVPHIRecipe::isCanonical (const InductionDescriptor &ID,
1095
- Type *Ty) const {
1096
- if (Ty != getScalarType ())
1099
+ bool VPCanonicalIVPHIRecipe::isCanonical (
1100
+ InductionDescriptor::InductionKind Kind, VPValue *Start, VPValue *Step,
1101
+ Type *Ty) const {
1102
+ // The types must match and it must be an integer induction.
1103
+ if (Ty != getScalarType () || Kind != InductionDescriptor::IK_IntInduction)
1104
+ return false ;
1105
+ // Start must match the start value of this canonical induction.
1106
+ if (Start != getStartValue ())
1097
1107
return false ;
1098
- // The start value of ID must match the start value of this canonical
1099
- // induction .
1100
- if (getStartValue ()-> getLiveInIRValue () != ID. getStartValue ())
1108
+
1109
+ // If the step is defined by a recipe, it is not a ConstantInt .
1110
+ if (Step-> getDefiningRecipe ())
1101
1111
return false ;
1102
1112
1103
- ConstantInt *Step = ID.getConstIntStepValue ();
1104
- // ID must also be incremented by one. IK_IntInduction always increment the
1105
- // induction by Step, but the binary op may not be set.
1106
- return ID.getKind () == InductionDescriptor::IK_IntInduction && Step &&
1107
- Step->isOne ();
1113
+ ConstantInt *StepC = dyn_cast<ConstantInt>(Step->getLiveInIRValue ());
1114
+ return StepC && StepC->isOne ();
1108
1115
}
1109
1116
1110
1117
bool VPWidenPointerInductionRecipe::onlyScalarsGenerated (ElementCount VF) {
0 commit comments