Skip to content

Commit 10610bc

Browse files
committed
!fixup address latest comments, thanks
1 parent bcbcf3b commit 10610bc

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
@@ -7697,7 +7697,7 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
76977697
((VectorizingEpilogue && ExpandedSCEVs) ||
76987698
(!VectorizingEpilogue && !ExpandedSCEVs)) &&
76997699
"expanded SCEVs to reuse can only be used during epilogue vectorization");
7700-
VPlanTransforms::materializeBroadcasts(BestVPlan);
7700+
VPlanTransforms::materializeLiveInBroadcasts(BestVPlan);
77017701
// TODO: Move to VPlan transform stage once the transition to the VPlan-based
77027702
// cost model is complete for better cost estimates.
77037703
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

@@ -3712,7 +3712,14 @@ class VPlan {
37123712
VPValue *getLiveIn(Value *V) const { return Value2VPValue.lookup(V); }
37133713

37143714
/// Return the list of live-in VPValues available in the VPlan.
3715-
ArrayRef<VPValue *> getLiveIns() const { return VPLiveIns; }
3715+
ArrayRef<VPValue *> getLiveIns() const {
3716+
assert(all_of(Value2VPValue,
3717+
[this](const auto &P) {
3718+
return is_contained(VPLiveIns, P.second);
3719+
}) &&
3720+
"all VPValues in Value2VPValue must also be in VPLiveIns");
3721+
return VPLiveIns;
3722+
}
37163723

37173724
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
37183725
/// 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
@@ -2113,11 +2113,13 @@ void VPlanTransforms::handleUncountableEarlyExit(
21132113
LatchExitingBranch->eraseFromParent();
21142114
}
21152115

2116-
void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
2116+
void VPlanTransforms::materializeLiveInBroadcasts(VPlan &Plan) {
21172117
VPDominatorTree VPDT;
21182118
VPDT.recalculate(Plan);
21192119
auto *VectorPreheader = Plan.getVectorPreheader();
21202120
VPBuilder Builder(VectorPreheader);
2121+
if (Plan.hasScalarVFOnly())
2122+
return;
21212123
for (VPValue *LiveIn : Plan.getLiveIns()) {
21222124
if (all_of(LiveIn->users(),
21232125
[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)