Skip to content

Commit 386dc5b

Browse files
committed
!fixup address latest comments, thanks
1 parent 5795e40 commit 386dc5b

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7666,7 +7666,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
76667666
((VectorizingEpilogue && ExpandedSCEVs) ||
76677667
(!VectorizingEpilogue && !ExpandedSCEVs)) &&
76687668
"expanded SCEVs to reuse can only be used during epilogue vectorization");
7669-
VPlanTransforms::materializeBroadcasts(BestVPlan);
7669+
VPlanTransforms::materializeLiveInBroadcasts(BestVPlan);
76707670
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
76717671
// cost model is complete for better cost estimates.
76727672
VPlanTransforms::runPass(VPlanTransforms::unrollByUF, BestVPlan, BestUF,

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags {
15711571
bool onlyFirstLaneUsed(const VPValue *Op) const override {
15721572
assert(is_contained(operands(), Op) &&
15731573
"Op must be an operand of the recipe");
1574-
return Op == getOperand(0);
1574+
return Op == getOperand(0) && isPointerLoopInvariant();
15751575
}
15761576
};
15771577

@@ -3770,7 +3770,14 @@ class VPlan {
37703770
VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); }
37713771

37723772
/// Return the list of live-in VPValues available in the VPlan.
3773-
ArrayRef<VPValue *> getLiveIns() const { return VPLiveIns; }
3773+
ArrayRef<VPValue *> getLiveIns() const {
3774+
assert(all_of(Value2VPValue,
3775+
[this](const auto &P) {
3776+
return is_contained(VPLiveIns, P.second);
3777+
}) &&
3778+
"all VPValues in Value2VPValue must also be in VPLiveIns");
3779+
return VPLiveIns;
3780+
}
37743781

37753782
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
37763783
/// Print the live-ins of this VPlan to \p O.

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
9292
return IntegerType::get(Ctx, 1);
9393
case VPInstruction::Broadcast:
9494
case VPInstruction::PtrAdd:
95-
// Return the type based on the pointer argument (i.e. first operand).
95+
// Return the type based on first operand.
9696
return inferScalarType(R->getOperand(0));
9797
case VPInstruction::BranchOnCond:
9898
case VPInstruction::BranchOnCount:

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2152,11 +2152,13 @@ void VPlanTransforms::handleUncountableEarlyExit(
21522152
LatchExitingBranch->eraseFromParent();
21532153
}
21542154

2155-
void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
2155+
void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
21562156
VPDominatorTree VPDT;
21572157
VPDT.recalculate(Plan);
21582158
auto *VectorPreheader = Plan.getVectorPreheader();
21592159
VPBuilder Builder(VectorPreheader);
2160+
if (Plan.hasScalarVFOnly())
2161+
return;
21602162
for (VPValue *LiveIn : Plan.getLiveIns()) {
21612163
if (all_of(LiveIn->users(),
21622164
[LiveIn](VPUser *U) {

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct VPlanTransforms {
175175
DenseMap<VPValue *, VPValue *> &EndValues);
176176

177177
/// Add explicit broadcasts for live-ins used as vectors.
178-
static void materializeBroadcasts(VPlan &Plan);
178+
static void materializeLiveInBroadcasts(VPlan &Plan);
179179
};
180180

181181
} // namespace llvm

0 commit comments

Comments
 (0)