Skip to content

Commit d5fe7ce

Browse files
committed
Address Review Comments
- Use cast rather than dyn_cast - Remove unrolling test - Be explicit about APInt type. - Add comment
1 parent fec71fc commit d5fe7ce

File tree

2 files changed

+7
-4165
lines changed

2 files changed

+7
-4165
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,10 +1015,10 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
10151015

10161016
// Calculate the widest type required for known TC, VF and UF.
10171017
auto ComputeBitWidth = [](APInt TC, uint64_t Align) {
1018-
auto AlignedTC =
1018+
APInt AlignedTC =
10191019
Align * APIntOps::RoundingUDiv(TC, APInt(TC.getBitWidth(), Align),
10201020
APInt::Rounding::UP);
1021-
auto MaxVal = AlignedTC - 1;
1021+
APInt MaxVal = AlignedTC - 1;
10221022
return std::max<unsigned>(PowerOf2Ceil(MaxVal.getActiveBits()), 8);
10231023
};
10241024
unsigned NewBitWidth =
@@ -1032,6 +1032,10 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
10321032
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
10331033
for (VPRecipeBase &Phi : HeaderVPBB->phis()) {
10341034
auto *WideIV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&Phi);
1035+
1036+
// Currently only handle canonical IVs as it is trivial to replace the start
1037+
// and stop values, and we only perform the optimisation when the IV is only
1038+
// used by the comparison controlling loop control-flow.
10351039
if (!WideIV || !WideIV->isCanonical() ||
10361040
WideIV->hasMoreThanOneUniqueUser() ||
10371041
NewIVTy == WideIV->getScalarType())
@@ -1055,7 +1059,7 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
10551059
auto *NewBTC = new VPWidenCastRecipe(
10561060
Instruction::Trunc, Plan.getOrCreateBackedgeTakenCount(), NewIVTy);
10571061
Plan.getVectorPreheader()->appendRecipe(NewBTC);
1058-
auto *Cmp = dyn_cast<VPInstruction>(*WideIV->user_begin());
1062+
auto *Cmp = cast<VPInstruction>(*WideIV->user_begin());
10591063
Cmp->setOperand(1, NewBTC);
10601064

10611065
MadeChange = true;

0 commit comments

Comments
 (0)