Skip to content

Commit 7dae35d

Browse files
committed
Address review comments
1 parent 57998f8 commit 7dae35d

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7553,7 +7553,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {
75537553
CM.CostKind);
75547554
precomputeCosts(BestPlan, BestFactor.Width, CostCtx);
75557555
assert((BestFactor.Width == LegacyVF.Width ||
7556-
Legal->hasUncountableEarlyExit() ||
7556+
BestPlan.hasRegionWithEarlyExit() ||
75577557
planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),
75587558
CostCtx, OrigLoop) ||
75597559
planContainsAdditionalSimplifications(getPlanFor(LegacyVF.Width),

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,6 +3623,15 @@ class VPlan {
36233623
/// of VPBlockShallowTraversalWrapper.
36243624
auto getExitBlocks();
36253625

3626+
/// Returns true if the plan has a region containing an early exit, i.e. the
3627+
/// loop exits due to a condition other than testing the canonical induction
3628+
/// variable against the trip count.
3629+
bool hasRegionWithEarlyExit() {
3630+
auto *VectorRegion = getVectorLoopRegion();
3631+
return VectorRegion &&
3632+
VectorRegion->getSingleSuccessor() != getMiddleBlock();
3633+
}
3634+
36263635
/// Returns true if \p VPBB is an exit block.
36273636
bool isExitBlock(VPBlockBase *VPBB);
36283637

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -715,9 +715,9 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
715715
VPCostContext &Ctx) const {
716716
switch (getOpcode()) {
717717
case VPInstruction::AnyOf: {
718-
auto *VecI1Ty = VectorType::get(Type::getInt1Ty(Ctx.LLVMCtx), VF);
719-
return Ctx.TTI.getArithmeticReductionCost(Instruction::Or, VecI1Ty,
720-
std::nullopt, Ctx.CostKind);
718+
auto *VecTy = toVectorTy(Ctx.Types.inferScalarType(this), VF);
719+
return Ctx.TTI.getArithmeticReductionCost(
720+
Instruction::Or, cast<VectorType>(VecTy), std::nullopt, Ctx.CostKind);
721721
}
722722
default:
723723
// TODO: Fill out other opcodes!

0 commit comments

Comments
 (0)