@@ -1105,10 +1105,10 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
11051105
11061106 // Calculate the widest type required for known TC, VF and UF.
11071107 auto ComputeBitWidth = [](APInt TC, uint64_t Align) {
1108- auto AlignedTC =
1108+ APInt AlignedTC =
11091109 Align * APIntOps::RoundingUDiv (TC, APInt (TC.getBitWidth (), Align),
11101110 APInt::Rounding::UP);
1111- auto MaxVal = AlignedTC - 1 ;
1111+ APInt MaxVal = AlignedTC - 1 ;
11121112 return std::max<unsigned >(PowerOf2Ceil (MaxVal.getActiveBits ()), 8 );
11131113 };
11141114 unsigned NewBitWidth =
@@ -1122,6 +1122,10 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
11221122 VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion ()->getEntryBasicBlock ();
11231123 for (VPRecipeBase &Phi : HeaderVPBB->phis ()) {
11241124 auto *WideIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
1125+
1126+ // Currently only handle canonical IVs as it is trivial to replace the start
1127+ // and stop values, and we only perform the optimisation when the IV is only
1128+ // used by the comparison controlling loop control-flow.
11251129 if (!WideIV || !WideIV->isCanonical () ||
11261130 WideIV->hasMoreThanOneUniqueUser () ||
11271131 NewIVTy == WideIV->getScalarType ())
@@ -1145,7 +1149,7 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
11451149 auto *NewBTC = new VPWidenCastRecipe (
11461150 Instruction::Trunc, Plan.getOrCreateBackedgeTakenCount (), NewIVTy);
11471151 Plan.getVectorPreheader ()->appendRecipe (NewBTC);
1148- auto *Cmp = dyn_cast <VPInstruction>(*WideIV->user_begin ());
1152+ auto *Cmp = cast <VPInstruction>(*WideIV->user_begin ());
11491153 Cmp->setOperand (1 , NewBTC);
11501154
11511155 MadeChange = true ;
0 commit comments