Skip to content

Commit 6a575e2

Browse files
committed
Address comments
- refine stale comments - sink to use - add inbounds in print()
1 parent 142ea90 commit 6a575e2

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,8 +1834,7 @@ class VPReverseVectorPointerRecipe : public VPRecipeWithIRFlags,
18341834
#endif
18351835
};
18361836

1837-
/// A recipe to compute the pointers for widened memory accesses of IndexTy for
1838-
/// all parts.
1837+
/// A recipe to compute the pointers for widened memory accesses of IndexTy.
18391838
class VPVectorPointerRecipe : public VPRecipeWithIRFlags,
18401839
public VPUnrollPartAccessor<1> {
18411840
Type *IndexedTy;

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent,
18131813
}
18141814
#endif
18151815

1816-
void VPReverseVectorPointerRecipe ::execute(VPTransformState &State) {
1816+
void VPReverseVectorPointerRecipe::execute(VPTransformState &State) {
18171817
auto &Builder = State.Builder;
18181818
State.setDebugLocFrom(getDebugLoc());
18191819
unsigned CurrentPart = getUnrollPart(*this);
@@ -1823,8 +1823,6 @@ void VPReverseVectorPointerRecipe ::execute(VPTransformState &State) {
18231823
Type *IndexTy = State.VF.isScalable()
18241824
? DL.getIndexType(IndexedTy->getPointerTo())
18251825
: Builder.getInt32Ty();
1826-
Value *Ptr = State.get(getOperand(0), VPLane(0));
1827-
bool InBounds = isInBounds();
18281826

18291827
// The wide store needs to start at the last vector element.
18301828
Value *RunTimeVF = State.get(getVFValue(), VPLane(0));
@@ -1835,6 +1833,8 @@ void VPReverseVectorPointerRecipe ::execute(VPTransformState &State) {
18351833
ConstantInt::get(IndexTy, -(int64_t)CurrentPart), RunTimeVF);
18361834
// LastLane = 1 - RunTimeVF
18371835
Value *LastLane = Builder.CreateSub(ConstantInt::get(IndexTy, 1), RunTimeVF);
1836+
Value *Ptr = State.get(getOperand(0), VPLane(0));
1837+
bool InBounds = isInBounds();
18381838
Value *ResultPtr = Builder.CreateGEP(IndexedTy, Ptr, NumElt, "", InBounds);
18391839
ResultPtr = Builder.CreateGEP(IndexedTy, ResultPtr, LastLane, "", InBounds);
18401840

@@ -1847,11 +1847,13 @@ void VPReverseVectorPointerRecipe::print(raw_ostream &O, const Twine &Indent,
18471847
O << Indent;
18481848
printAsOperand(O, SlotTracker);
18491849
O << " = reverse-vector-pointer ";
1850+
if (isInBounds())
1851+
O << "inbounds ";
18501852
printOperands(O, SlotTracker);
18511853
}
18521854
#endif
18531855

1854-
void VPVectorPointerRecipe ::execute(VPTransformState &State) {
1856+
void VPVectorPointerRecipe::execute(VPTransformState &State) {
18551857
auto &Builder = State.Builder;
18561858
State.setDebugLocFrom(getDebugLoc());
18571859
unsigned CurrentPart = getUnrollPart(*this);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
7474
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
7575
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
7676
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
77-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer ir<%arrayidx>, vp<[[VF]]>
77+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
7878
; CHECK-NEXT: WIDEN ir<%1> = load vp<[[VEC_PTR]]>
7979
; CHECK-NEXT: WIDEN ir<%add9> = add ir<%1>, ir<1>
8080
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
81-
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer ir<%arrayidx3>, vp<[[VF]]>
81+
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
8282
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR2]]>, ir<%add9>
8383
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
8484
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
@@ -159,11 +159,11 @@ define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocaptur
159159
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
160160
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
161161
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
162-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer ir<%arrayidx>, vp<[[VF]]>
162+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
163163
; CHECK-NEXT: WIDEN ir<%13> = load vp<[[VEC_PTR]]>
164164
; CHECK-NEXT: WIDEN ir<%add9> = add ir<%13>, ir<1>
165165
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
166-
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer ir<%arrayidx3>, vp<[[VF]]>
166+
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
167167
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR2]]>, ir<%add9>
168168
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
169169
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
@@ -280,11 +280,11 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
280280
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
281281
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
282282
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
283-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer ir<%arrayidx>, vp<[[VF]]>
283+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
284284
; CHECK-NEXT: WIDEN ir<%1> = load vp<[[VEC_PTR]]>
285285
; CHECK-NEXT: WIDEN ir<%conv1> = fadd ir<%1>, ir<1.000000e+00>
286286
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
287-
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer ir<%arrayidx3>, vp<[[VF]]>
287+
; CHECK-NEXT: vp<[[VEC_PTR2:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
288288
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR2]]>, ir<%conv1>
289289
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
290290
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
@@ -365,11 +365,11 @@ define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocaptur
365365
; CHECK-NEXT: CLONE ir<%i.0> = add nsw vp<[[STEPS]]>, ir<-1>
366366
; CHECK-NEXT: CLONE ir<%idxprom> = zext ir<%i.0>
367367
; CHECK-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%B>, ir<%idxprom>
368-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer ir<%arrayidx>, vp<[[VF]]>
368+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx>, vp<[[VF]]>
369369
; CHECK-NEXT: WIDEN ir<%13> = load vp<[[VEC_PTR]]>
370370
; CHECK-NEXT: WIDEN ir<%conv1> = fadd ir<%13>, ir<1.000000e+00>
371371
; CHECK-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%A>, ir<%idxprom>
372-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer ir<%arrayidx3>, vp<[[VF]]>
372+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%arrayidx3>, vp<[[VF]]>
373373
; CHECK-NEXT: WIDEN store vp<[[VEC_PTR]]>, ir<%conv1>
374374
; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT:%.+]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
375375
; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[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
@@ -1120,7 +1120,7 @@ define void @ptr_induction_remove_dead_recipe(ptr %start, ptr %end) {
11201120
; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[DEV_IV]]>, ir<-1>
11211121
; CHECK-NEXT: EMIT vp<[[PTR_IV:%.+]]> = ptradd ir<%start>, vp<[[STEPS]]>
11221122
; CHECK-NEXT: CLONE ir<%ptr.iv.next> = getelementptr inbounds vp<[[PTR_IV]]>, ir<-1>
1123-
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer ir<%ptr.iv.next>, vp<[[VF]]>
1123+
; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = reverse-vector-pointer inbounds ir<%ptr.iv.next>, vp<[[VF]]>
11241124
; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VEC_PTR]]>
11251125
; CHECK-NEXT: WIDEN ir<%c.1> = icmp eq ir<%l>, ir<0>
11261126
; CHECK-NEXT: EMIT vp<[[NEG:%.+]]> = not ir<%c.1>

0 commit comments

Comments
 (0)