Skip to content

Commit a4dc02c

Browse files
authored
[VPlan] Rename VPReverseVectorPointerRecipe to VPVectorEndPointerRecipe. NFC (#131086)
After #128718 lands there will be two ways of performing a reversed widened memory access, either by performing a consecutive unit-stride access and a reverse, or a strided access with a negative stride. Even though both produce a reversed vector, only the former needs VPReverseVectorPointerRecipe which computes a pointer to the last element of each part. A strided reverse still needs a pointer to the first element of each part so it will use VPVectorPointerRecipe. This renames VPReverseVectorPointerRecipe to VPVectorEndPointerRecipe to clarify that a reversed access may not necessarily need a pointer to the last element.
1 parent b391e80 commit a4dc02c

File tree

10 files changed

+36
-36
lines changed

10 files changed

+36
-36
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,7 +4500,7 @@ static bool willGenerateVectors(VPlan &Plan, ElementCount VF,
45004500
case VPDef::VPInstructionSC:
45014501
case VPDef::VPCanonicalIVPHISC:
45024502
case VPDef::VPVectorPointerSC:
4503-
case VPDef::VPReverseVectorPointerSC:
4503+
case VPDef::VPVectorEndPointerSC:
45044504
case VPDef::VPExpandSCEVSC:
45054505
case VPDef::VPEVLBasedIVPHISC:
45064506
case VPDef::VPPredInstPHISC:
@@ -8352,7 +8352,7 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
83528352
(CM.foldTailByMasking() || !GEP || !GEP->isInBounds())
83538353
? GEPNoWrapFlags::none()
83548354
: GEPNoWrapFlags::inBounds();
8355-
VectorPtr = new VPReverseVectorPointerRecipe(
8355+
VectorPtr = new VPVectorEndPointerRecipe(
83568356
Ptr, &Plan.getVF(), getLoadStoreType(I), Flags, I->getDebugLoc());
83578357
} else {
83588358
VectorPtr = new VPVectorPointerRecipe(Ptr, getLoadStoreType(I),

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
514514
case VPRecipeBase::VPReplicateSC:
515515
case VPRecipeBase::VPScalarIVStepsSC:
516516
case VPRecipeBase::VPVectorPointerSC:
517-
case VPRecipeBase::VPReverseVectorPointerSC:
517+
case VPRecipeBase::VPVectorEndPointerSC:
518518
case VPRecipeBase::VPWidenCallSC:
519519
case VPRecipeBase::VPWidenCanonicalIVSC:
520520
case VPRecipeBase::VPWidenCastSC:
@@ -714,7 +714,7 @@ class VPRecipeWithIRFlags : public VPSingleDefRecipe {
714714
R->getVPDefID() == VPRecipeBase::VPReductionSC ||
715715
R->getVPDefID() == VPRecipeBase::VPReductionEVLSC ||
716716
R->getVPDefID() == VPRecipeBase::VPReplicateSC ||
717-
R->getVPDefID() == VPRecipeBase::VPReverseVectorPointerSC ||
717+
R->getVPDefID() == VPRecipeBase::VPVectorEndPointerSC ||
718718
R->getVPDefID() == VPRecipeBase::VPVectorPointerSC;
719719
}
720720

@@ -1511,20 +1511,21 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags {
15111511
}
15121512
};
15131513

1514-
/// A recipe to compute the pointers for widened memory accesses of IndexTy
1515-
/// in reverse order.
1516-
class VPReverseVectorPointerRecipe : public VPRecipeWithIRFlags,
1517-
public VPUnrollPartAccessor<2> {
1514+
/// A recipe to compute a pointer to the last element of each part of a widened
1515+
/// memory access for widened memory accesses of IndexedTy. Used for
1516+
/// VPWidenMemoryRecipes that are reversed.
1517+
class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags,
1518+
public VPUnrollPartAccessor<2> {
15181519
Type *IndexedTy;
15191520

15201521
public:
1521-
VPReverseVectorPointerRecipe(VPValue *Ptr, VPValue *VF, Type *IndexedTy,
1522-
GEPNoWrapFlags GEPFlags, DebugLoc DL)
1523-
: VPRecipeWithIRFlags(VPDef::VPReverseVectorPointerSC,
1522+
VPVectorEndPointerRecipe(VPValue *Ptr, VPValue *VF, Type *IndexedTy,
1523+
GEPNoWrapFlags GEPFlags, DebugLoc DL)
1524+
: VPRecipeWithIRFlags(VPDef::VPVectorEndPointerSC,
15241525
ArrayRef<VPValue *>({Ptr, VF}), GEPFlags, DL),
15251526
IndexedTy(IndexedTy) {}
15261527

1527-
VP_CLASSOF_IMPL(VPDef::VPReverseVectorPointerSC)
1528+
VP_CLASSOF_IMPL(VPDef::VPVectorEndPointerSC)
15281529

15291530
VPValue *getVFValue() { return getOperand(1); }
15301531
const VPValue *getVFValue() const { return getOperand(1); }
@@ -1552,10 +1553,9 @@ class VPReverseVectorPointerRecipe : public VPRecipeWithIRFlags,
15521553
return true;
15531554
}
15541555

1555-
VPReverseVectorPointerRecipe *clone() override {
1556-
return new VPReverseVectorPointerRecipe(getOperand(0), getVFValue(),
1557-
IndexedTy, getGEPNoWrapFlags(),
1558-
getDebugLoc());
1556+
VPVectorEndPointerRecipe *clone() override {
1557+
return new VPVectorEndPointerRecipe(getOperand(0), getVFValue(), IndexedTy,
1558+
getGEPNoWrapFlags(), getDebugLoc());
15591559
}
15601560

15611561
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ Type *VPTypeAnalysis::inferScalarType(const VPValue *V) {
255255
[](const auto *R) { return R->getScalarType(); })
256256
.Case<VPReductionRecipe, VPPredInstPHIRecipe, VPWidenPHIRecipe,
257257
VPScalarIVStepsRecipe, VPWidenGEPRecipe, VPVectorPointerRecipe,
258-
VPReverseVectorPointerRecipe, VPWidenCanonicalIVRecipe,
258+
VPVectorEndPointerRecipe, VPWidenCanonicalIVRecipe,
259259
VPPartialReductionRecipe>([this](const VPRecipeBase *R) {
260260
return inferScalarType(R->getOperand(0));
261261
})

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ bool VPRecipeBase::mayHaveSideEffects() const {
148148
case VPDerivedIVSC:
149149
case VPPredInstPHISC:
150150
case VPScalarCastSC:
151-
case VPReverseVectorPointerSC:
151+
case VPVectorEndPointerSC:
152152
return false;
153153
case VPInstructionSC:
154154
return mayWriteToMemory();
@@ -2145,7 +2145,7 @@ static Type *getGEPIndexTy(bool IsScalable, bool IsReverse,
21452145
: Builder.getInt32Ty();
21462146
}
21472147

2148-
void VPReverseVectorPointerRecipe::execute(VPTransformState &State) {
2148+
void VPVectorEndPointerRecipe::execute(VPTransformState &State) {
21492149
auto &Builder = State.Builder;
21502150
State.setDebugLocFrom(getDebugLoc());
21512151
unsigned CurrentPart = getUnrollPart(*this);
@@ -2171,11 +2171,11 @@ void VPReverseVectorPointerRecipe::execute(VPTransformState &State) {
21712171
}
21722172

21732173
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2174-
void VPReverseVectorPointerRecipe::print(raw_ostream &O, const Twine &Indent,
2175-
VPSlotTracker &SlotTracker) const {
2174+
void VPVectorEndPointerRecipe::print(raw_ostream &O, const Twine &Indent,
2175+
VPSlotTracker &SlotTracker) const {
21762176
O << Indent;
21772177
printAsOperand(O, SlotTracker);
2178-
O << " = reverse-vector-pointer";
2178+
O << " = vector-end-pointer";
21792179
printFlags(O);
21802180
printOperands(O, SlotTracker);
21812181
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
17681768
}
17691769

17701770
for (VPUser *U : to_vector(Plan.getVF().users())) {
1771-
if (auto *R = dyn_cast<VPReverseVectorPointerRecipe>(U))
1771+
if (auto *R = dyn_cast<VPVectorEndPointerRecipe>(U))
17721772
R->setOperand(1, &EVL);
17731773
}
17741774

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,12 @@ void UnrollState::unrollRecipeByUF(VPRecipeBase &R) {
311311
// Add operand indicating the part to generate code for, to recipes still
312312
// requiring it.
313313
if (isa<VPScalarIVStepsRecipe, VPWidenCanonicalIVRecipe,
314-
VPVectorPointerRecipe, VPReverseVectorPointerRecipe>(Copy) ||
314+
VPVectorPointerRecipe, VPVectorEndPointerRecipe>(Copy) ||
315315
match(Copy, m_VPInstruction<VPInstruction::CanonicalIVIncrementForPart>(
316316
m_VPValue())))
317317
Copy->addOperand(getConstantVPV(Part));
318318

319-
if (isa<VPVectorPointerRecipe, VPReverseVectorPointerRecipe>(R))
319+
if (isa<VPVectorPointerRecipe, VPVectorEndPointerRecipe>(R))
320320
Copy->setOperand(0, R.getOperand(0));
321321
}
322322
}

llvm/lib/Transforms/Vectorize/VPlanValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class VPDef {
335335
VPScalarCastSC,
336336
VPScalarIVStepsSC,
337337
VPVectorPointerSC,
338-
VPReverseVectorPointerSC,
338+
VPVectorEndPointerSC,
339339
VPWidenCallSC,
340340
VPWidenCanonicalIVSC,
341341
VPWidenCastSC,

llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool VPlanVerifier::verifyEVLRecipe(const VPInstruction &EVL) const {
145145
})
146146
.Case<VPWidenStoreEVLRecipe, VPReductionEVLRecipe>(
147147
[&](const VPRecipeBase *S) { return VerifyEVLUse(*S, 2); })
148-
.Case<VPWidenLoadEVLRecipe, VPReverseVectorPointerRecipe>(
148+
.Case<VPWidenLoadEVLRecipe, VPVectorEndPointerRecipe>(
149149
[&](const VPRecipeBase *R) { return VerifyEVLUse(*R, 1); })
150150
.Case<VPScalarCastRecipe>(
151151
[&](const VPScalarCastRecipe *S) { return VerifyEVLUse(*S, 0); })

llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
7676
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
7777
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
7878
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
79-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
79+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-end-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
8080
; CHECK-NEXT: WIDEN ir<%1> = load vp<[[VEC_PTR]]>
8181
; CHECK-NEXT: WIDEN ir<%add9> = add ir<%1>, ir<1>
8282
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
83-
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
83+
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = vector-end-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
8484
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR2]]>, ir<%add9>
8585
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
8686
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
@@ -199,11 +199,11 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
199199
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
200200
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
201201
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
202-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, ir<[[VF]]>
202+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-end-pointer inbounds ir<%arrayidx>, ir<[[VF]]>
203203
; CHECK-NEXT: WIDEN ir<[[L:%.+]]> = load vp<[[VEC_PTR]]>
204204
; CHECK-NEXT: WIDEN ir<%add9> = add ir<[[L]]>, ir<1>
205205
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
206-
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, ir<[[VF]]>
206+
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = vector-end-pointer inbounds ir<%arrayidx3>, ir<[[VF]]>
207207
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR2]]>, ir<%add9>
208208
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV]]>, ir<[[VFxUF]]>.1
209209
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, ir<[[VEC_TC]]>
@@ -325,11 +325,11 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
325325
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
326326
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
327327
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
328-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
328+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-end-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
329329
; CHECK-NEXT: WIDEN ir<%1> = load vp<[[VEC_PTR]]>
330330
; CHECK-NEXT: WIDEN ir<%conv1> = fadd ir<%1>, ir<1.000000e+00>
331331
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
332-
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
332+
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = vector-end-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
333333
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR2]]>, ir<%conv1>
334334
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
335335
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
@@ -448,11 +448,11 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
448448
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
449449
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
450450
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
451-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, ir<[[VF]]>
451+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-end-pointer inbounds ir<%arrayidx>, ir<[[VF]]>
452452
; CHECK-NEXT: WIDEN ir<[[L:%.+]]> = load vp<[[VEC_PTR]]>
453453
; CHECK-NEXT: WIDEN ir<%conv1> = fadd ir<[[L]]>, ir<1.000000e+00>
454454
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
455-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, ir<[[VF]]>
455+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-end-pointer inbounds ir<%arrayidx3>, ir<[[VF]]>
456456
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR]]>, ir<%conv1>
457457
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV]]>, ir<[[VFxUF]]>.1
458458
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, ir<[[VEC_TC]]>

llvm/test/Transforms/LoopVectorize/vplan-sink-scalars-and-merge.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ define void @ptr_induction_remove_dead_recipe(ptr %start, ptr %end) {
11471147
; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[DEV_IV]]>, ir<-1>
11481148
; CHECK-NEXT: EMIT vp<[[PTR_IV:%.+]]> = ptradd ir<%start>, vp<[[STEPS]]>
11491149
; CHECK-NEXT: CLONE ir<%ptr.iv.next> = getelementptr inbounds vp<[[PTR_IV]]>, ir<-1>
1150-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%ptr.iv.next>, vp<[[VF]]>
1150+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-end-pointer inbounds ir<%ptr.iv.next>, vp<[[VF]]>
11511151
; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VEC_PTR]]>
11521152
; CHECK-NEXT: WIDEN ir<%c.1> = icmp eq ir<%l>, ir<0>
11531153
; CHECK-NEXT: EMIT vp<[[NEG:%.+]]> = not ir<%c.1>

0 commit comments

Comments
 (0)