Skip to content

Commit 8a70701

Browse files
committed
!fixup address latest comments, thanks
1 parent a48612c commit 8a70701

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
@@ -7696,7 +7696,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
76967696
((VectorizingEpilogue && ExpandedSCEVs) ||
76977697
(!VectorizingEpilogue && !ExpandedSCEVs)) &&
76987698
"expanded SCEVs to reuse can only be used during epilogue vectorization");
7699-
VPlanTransforms::materializeBroadcasts(BestVPlan);
7699+
VPlanTransforms::materializeLiveInBroadcasts(BestVPlan);
77007700
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
77017701
// cost model is complete for better cost estimates.
77027702
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
@@ -1520,7 +1520,7 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags {
15201520
bool onlyFirstLaneUsed(const VPValue *Op) const override {
15211521
assert(is_contained(operands(), Op) &&
15221522
"Op must be an operand of the recipe");
1523-
return Op == getOperand(0);
1523+
return Op == getOperand(0) && isPointerLoopInvariant();
15241524
}
15251525
};
15261526

@@ -3705,7 +3705,14 @@ class VPlan {
37053705
VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); }
37063706

37073707
/// Return the list of live-in VPValues available in the VPlan.
3708-
ArrayRef<VPValue *> getLiveIns() const { return VPLiveIns; }
3708+
ArrayRef<VPValue *> getLiveIns() const {
3709+
assert(all_of(Value2VPValue,
3710+
[this](const auto &P) {
3711+
return is_contained(VPLiveIns, P.second);
3712+
}) &&
3713+
"all VPValues in Value2VPValue must also be in VPLiveIns");
3714+
return VPLiveIns;
3715+
}
37093716

37103717
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
37113718
/// 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
@@ -2122,11 +2122,13 @@ void VPlanTransforms::handleUncountableEarlyExit(
21222122
LatchExitingBranch->eraseFromParent();
21232123
}
21242124

2125-
void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
2125+
void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
21262126
VPDominatorTree VPDT;
21272127
VPDT.recalculate(Plan);
21282128
auto *VectorPreheader = Plan.getVectorPreheader();
21292129
VPBuilder Builder(VectorPreheader);
2130+
if (Plan.hasScalarVFOnly())
2131+
return;
21302132
for (VPValue *LiveIn : Plan.getLiveIns()) {
21312133
if (all_of(LiveIn->users(),
21322134
[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)