Skip to content

Commit 4a5df13

Browse files
committed
!fixup address commenst, thanks
1 parent 5b1c101 commit 4a5df13

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8240,9 +8240,9 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
82408240
// the vector loop or when not folding the tail. In the later case, we know
82418241
// that the canonical induction increment will not overflow as the vector trip
82428242
// count is >= increment and a multiple of the increment.
8243+
VPRegionBlock *LoopRegion = Plan->getVectorLoopRegion();
82438244
bool HasNUW = !IVUpdateMayOverflow || Style == TailFoldingStyle::None;
82448245
if (!HasNUW) {
8245-
VPRegionBlock *LoopRegion = Plan->getVectorLoopRegion();
82468246
auto *IVInc =
82478247
LoopRegion->getExitingBasicBlock()->getTerminator()->getOperand(0);
82488248
assert(match(IVInc,
@@ -8293,7 +8293,6 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
82938293

82948294
// Scan the body of the loop in a topological order to visit each basic block
82958295
// after having visited its predecessor basic blocks.
8296-
VPRegionBlock *LoopRegion = Plan->getVectorLoopRegion();
82978296
VPBasicBlock *HeaderVPBB = LoopRegion->getEntryBasicBlock();
82988297
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
82998298
HeaderVPBB);

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4071,11 +4071,14 @@ class LLVM_ABI_FOR_TEST VPRegionBlock : public VPBlockBase {
40714071
VPCanonicalIVPHIRecipe *getCanonicalIV() {
40724072
VPBasicBlock *EntryVPBB = getEntryBasicBlock();
40734073
if (EntryVPBB->empty()) {
4074-
// VPlan native path.
4074+
// VPlan native path. TODO: Unify both code paths.
40754075
EntryVPBB = cast<VPBasicBlock>(EntryVPBB->getSingleSuccessor());
40764076
}
40774077
return cast<VPCanonicalIVPHIRecipe>(&*EntryVPBB->begin());
40784078
}
4079+
const VPCanonicalIVPHIRecipe *getCanonicalIV() const {
4080+
return const_cast<VPRegionBlock *>(this)->getCanonicalIV();
4081+
}
40794082
};
40804083

40814084
/// VPlan models a candidate for vectorization, encoding various decisions take

llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ void VPPredicator::createHeaderMask(VPBasicBlock *HeaderVPBB, bool FoldTail) {
168168
// non-phi instructions.
169169

170170
auto &Plan = *HeaderVPBB->getPlan();
171-
auto *IV = new VPWidenCanonicalIVRecipe(
172-
Plan.getVectorLoopRegion()->getCanonicalIV());
171+
auto *IV =
172+
new VPWidenCanonicalIVRecipe(HeaderVPBB->getParent()->getCanonicalIV());
173173
Builder.setInsertPoint(HeaderVPBB, HeaderVPBB->getFirstNonPhi());
174174
Builder.insert(IV);
175175

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2344,7 +2344,7 @@ bool VPWidenIntOrFpInductionRecipe::isCanonical() const {
23442344
return false;
23452345
auto *StepC = dyn_cast<ConstantInt>(getStepValue()->getLiveInIRValue());
23462346
auto *StartC = dyn_cast<ConstantInt>(getStartValue()->getLiveInIRValue());
2347-
auto *CanIV = cast<VPCanonicalIVPHIRecipe>(&*getParent()->begin());
2347+
auto *CanIV = getParent()->getParent()->getCanonicalIV();
23482348
return StartC && StartC->isZero() && StepC && StepC->isOne() &&
23492349
getScalarType() == CanIV->getScalarType();
23502350
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
803803

804804
// Calculate the final index.
805805
VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
806-
VPValue *EndValue = LoopRegion->getCanonicalIV();
807-
auto CanonicalIVType = LoopRegion->getCanonicalIV()->getScalarType();
806+
auto *CanonicalIV = LoopRegion->getCanonicalIV();
807+
Type *CanonicalIVType = CanonicalIV->getScalarType();
808808
VPBuilder B(cast<VPBasicBlock>(PredVPBB));
809809

810810
DebugLoc DL = cast<VPInstruction>(Op)->getDebugLoc();
@@ -813,7 +813,8 @@ static VPValue *optimizeEarlyExitInductionUser(VPlan &Plan,
813813
Type *FirstActiveLaneType = TypeInfo.inferScalarType(FirstActiveLane);
814814
FirstActiveLane = B.createScalarZExtOrTrunc(FirstActiveLane, CanonicalIVType,
815815
FirstActiveLaneType, DL);
816-
EndValue = B.createNaryOp(Instruction::Add, {EndValue, FirstActiveLane}, DL);
816+
VPValue *EndValue =
817+
B.createNaryOp(Instruction::Add, {CanonicalIV, FirstActiveLane}, DL);
817818

818819
// `getOptimizableIVOf()` always returns the pre-incremented IV, so if it
819820
// changed it means the exit is using the incremented value, so we need to

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ bool vputils::isUniformAcrossVFsAndUFs(VPValue *V) {
105105
}
106106

107107
auto *CanonicalIV =
108-
R->getParent()->getPlan()->getVectorLoopRegion()->getCanonicalIV();
108+
R->getParent()->getEnclosingLoopRegion()->getCanonicalIV();
109109
// Canonical IV chain is uniform.
110110
if (V == CanonicalIV || V == CanonicalIV->getBackedgeValue())
111111
return true;

0 commit comments

Comments
 (0)