Skip to content

Commit 02c68b3

Browse files
authored
[VPlan] Plumb scalable register size through narrowInterleaveGroups (llvm#167505)
On RISC-V narrowInterleaveGroups doesn't kick in because the wrong VectorRegWidth is passed to isConsecutiveInterleaveGroup. narrowInterleaveGroups is always passed the RGK_FixedWidthVector register size, but on RISC-V the RGK_ScalableVector size is twice as large because we want to use LMUL 2. This causes the `GroupSize == VectorRegWidth` check to fail. This fixes it by using the scalable register size whenever the VF is scalable and plumbing it through as a potentially scalable TypeSize. Note that this only makes a difference when tail folding is disabled, as narrowInterleaveGroups can't handle EVL based IVs yet.
1 parent 57b2341 commit 02c68b3

File tree

4 files changed

+228
-10
lines changed

4 files changed

+228
-10
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7307,7 +7307,9 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
73077307

73087308
VPlanTransforms::narrowInterleaveGroups(
73097309
BestVPlan, BestVF,
7310-
TTI.getRegisterBitWidth(TargetTransformInfo::RGK_FixedWidthVector));
7310+
TTI.getRegisterBitWidth(BestVF.isScalable()
7311+
? TargetTransformInfo::RGK_ScalableVector
7312+
: TargetTransformInfo::RGK_FixedWidthVector));
73117313
VPlanTransforms::removeDeadRecipes(BestVPlan);
73127314

73137315
VPlanTransforms::convertToConcreteRecipes(BestVPlan);

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,8 +4177,9 @@ static bool canNarrowLoad(VPWidenRecipe *WideMember0, unsigned OpIdx,
41774177
/// members both equal to \p VF. The interleave group must also access the full
41784178
/// vector width \p VectorRegWidth.
41794179
static bool isConsecutiveInterleaveGroup(VPInterleaveRecipe *InterleaveR,
4180-
unsigned VF, VPTypeAnalysis &TypeInfo,
4181-
unsigned VectorRegWidth) {
4180+
ElementCount VF,
4181+
VPTypeAnalysis &TypeInfo,
4182+
TypeSize VectorRegWidth) {
41824183
if (!InterleaveR || InterleaveR->getMask())
41834184
return false;
41844185

@@ -4200,9 +4201,11 @@ static bool isConsecutiveInterleaveGroup(VPInterleaveRecipe *InterleaveR,
42004201
return false;
42014202
}
42024203

4203-
unsigned GroupSize = GroupElementTy->getScalarSizeInBits() * VF;
4204-
auto IG = InterleaveR->getInterleaveGroup();
4205-
return IG->getFactor() == VF && IG->getNumMembers() == VF &&
4204+
unsigned VFMin = VF.getKnownMinValue();
4205+
TypeSize GroupSize = TypeSize::get(
4206+
GroupElementTy->getScalarSizeInBits() * VFMin, VF.isScalable());
4207+
const auto *IG = InterleaveR->getInterleaveGroup();
4208+
return IG->getFactor() == VFMin && IG->getNumMembers() == VFMin &&
42064209
GroupSize == VectorRegWidth;
42074210
}
42084211

@@ -4268,14 +4271,13 @@ narrowInterleaveGroupOp(VPValue *V, SmallPtrSetImpl<VPValue *> &NarrowedOps) {
42684271
}
42694272

42704273
void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
4271-
unsigned VectorRegWidth) {
4274+
TypeSize VectorRegWidth) {
42724275
VPRegionBlock *VectorLoop = Plan.getVectorLoopRegion();
42734276
if (!VectorLoop || VectorLoop->getEntry()->getNumSuccessors() != 0)
42744277
return;
42754278

42764279
VPTypeAnalysis TypeInfo(Plan);
42774280

4278-
unsigned VFMinVal = VF.getKnownMinValue();
42794281
SmallVector<VPInterleaveRecipe *> StoreGroups;
42804282
for (auto &R : *VectorLoop->getEntryBasicBlock()) {
42814283
if (isa<VPCanonicalIVPHIRecipe>(&R))
@@ -4310,7 +4312,7 @@ void VPlanTransforms::narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
43104312
continue;
43114313

43124314
// Bail out on non-consecutive interleave groups.
4313-
if (!isConsecutiveInterleaveGroup(InterleaveR, VFMinVal, TypeInfo,
4315+
if (!isConsecutiveInterleaveGroup(InterleaveR, VF, TypeInfo,
43144316
VectorRegWidth))
43154317
return;
43164318

llvm/lib/Transforms/Vectorize/VPlanTransforms.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ struct VPlanTransforms {
349349
/// form of loop-aware SLP, where we use interleave groups to identify
350350
/// candidates.
351351
static void narrowInterleaveGroups(VPlan &Plan, ElementCount VF,
352-
unsigned VectorRegWidth);
352+
TypeSize VectorRegWidth);
353353

354354
/// Predicate and linearize the control-flow in the only loop region of
355355
/// \p Plan. If \p FoldTail is true, create a mask guarding the loop
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals none --version 6
2+
; RUN: opt -p loop-vectorize -mtriple riscv64 -mattr=+v -S %s | FileCheck -check-prefix=CHECK %s
3+
; RUN: opt -p loop-vectorize -mtriple riscv64 -mattr=+v -S %s -prefer-predicate-over-epilogue=scalar-epilogue | FileCheck -check-prefix=EPILOGUE %s
4+
5+
define void @load_store_interleave_group(ptr noalias %data) {
6+
; CHECK-LABEL: define void @load_store_interleave_group(
7+
; CHECK-SAME: ptr noalias [[DATA:%.*]]) #[[ATTR0:[0-9]+]] {
8+
; CHECK-NEXT: [[ENTRY:.*:]]
9+
; CHECK-NEXT: br label %[[VECTOR_PH:.*]]
10+
; CHECK: [[VECTOR_PH]]:
11+
; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
12+
; CHECK: [[VECTOR_BODY]]:
13+
; CHECK-NEXT: [[EVL_BASED_IV:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_EVL_NEXT:%.*]], %[[VECTOR_BODY]] ]
14+
; CHECK-NEXT: [[AVL:%.*]] = phi i64 [ 100, %[[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], %[[VECTOR_BODY]] ]
15+
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 2, i1 true)
16+
; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i64 [[EVL_BASED_IV]], 1
17+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i64, ptr [[DATA]], i64 [[TMP1]]
18+
; CHECK-NEXT: [[INTERLEAVE_EVL:%.*]] = mul nuw nsw i32 [[TMP0]], 2
19+
; CHECK-NEXT: [[WIDE_VP_LOAD:%.*]] = call <vscale x 4 x i64> @llvm.vp.load.nxv4i64.p0(ptr align 8 [[TMP2]], <vscale x 4 x i1> splat (i1 true), i32 [[INTERLEAVE_EVL]])
20+
; CHECK-NEXT: [[STRIDED_VEC:%.*]] = call { <vscale x 2 x i64>, <vscale x 2 x i64> } @llvm.vector.deinterleave2.nxv4i64(<vscale x 4 x i64> [[WIDE_VP_LOAD]])
21+
; CHECK-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 2 x i64>, <vscale x 2 x i64> } [[STRIDED_VEC]], 0
22+
; CHECK-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 2 x i64>, <vscale x 2 x i64> } [[STRIDED_VEC]], 1
23+
; CHECK-NEXT: [[INTERLEAVE_EVL1:%.*]] = mul nuw nsw i32 [[TMP0]], 2
24+
; CHECK-NEXT: [[INTERLEAVED_VEC:%.*]] = call <vscale x 4 x i64> @llvm.vector.interleave2.nxv4i64(<vscale x 2 x i64> [[TMP3]], <vscale x 2 x i64> [[TMP4]])
25+
; CHECK-NEXT: call void @llvm.vp.store.nxv4i64.p0(<vscale x 4 x i64> [[INTERLEAVED_VEC]], ptr align 8 [[TMP2]], <vscale x 4 x i1> splat (i1 true), i32 [[INTERLEAVE_EVL1]])
26+
; CHECK-NEXT: [[TMP5:%.*]] = zext i32 [[TMP0]] to i64
27+
; CHECK-NEXT: [[INDEX_EVL_NEXT]] = add nuw i64 [[TMP5]], [[EVL_BASED_IV]]
28+
; CHECK-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP5]]
29+
; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[AVL_NEXT]], 0
30+
; CHECK-NEXT: br i1 [[TMP6]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
31+
; CHECK: [[MIDDLE_BLOCK]]:
32+
; CHECK-NEXT: br label %[[EXIT:.*]]
33+
; CHECK: [[EXIT]]:
34+
; CHECK-NEXT: ret void
35+
;
36+
; EPILOGUE-LABEL: define void @load_store_interleave_group(
37+
; EPILOGUE-SAME: ptr noalias [[DATA:%.*]]) #[[ATTR0:[0-9]+]] {
38+
; EPILOGUE-NEXT: [[ENTRY:.*]]:
39+
; EPILOGUE-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
40+
; EPILOGUE-NEXT: [[TMP1:%.*]] = shl nuw i64 [[TMP0]], 1
41+
; EPILOGUE-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 100, [[TMP1]]
42+
; EPILOGUE-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
43+
; EPILOGUE: [[VECTOR_PH]]:
44+
; EPILOGUE-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
45+
; EPILOGUE-NEXT: [[TMP3:%.*]] = mul nuw i64 [[TMP2]], 2
46+
; EPILOGUE-NEXT: [[N_MOD_VF:%.*]] = urem i64 100, [[TMP3]]
47+
; EPILOGUE-NEXT: [[N_VEC:%.*]] = sub i64 100, [[N_MOD_VF]]
48+
; EPILOGUE-NEXT: br label %[[VECTOR_BODY:.*]]
49+
; EPILOGUE: [[VECTOR_BODY]]:
50+
; EPILOGUE-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
51+
; EPILOGUE-NEXT: [[TMP4:%.*]] = shl nsw i64 [[INDEX]], 1
52+
; EPILOGUE-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, ptr [[DATA]], i64 [[TMP4]]
53+
; EPILOGUE-NEXT: [[WIDE_LOAD:%.*]] = load <vscale x 2 x i64>, ptr [[TMP5]], align 8
54+
; EPILOGUE-NEXT: store <vscale x 2 x i64> [[WIDE_LOAD]], ptr [[TMP5]], align 8
55+
; EPILOGUE-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP2]]
56+
; EPILOGUE-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
57+
; EPILOGUE-NEXT: br i1 [[TMP8]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
58+
; EPILOGUE: [[MIDDLE_BLOCK]]:
59+
; EPILOGUE-NEXT: [[CMP_N:%.*]] = icmp eq i64 100, [[N_VEC]]
60+
; EPILOGUE-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]
61+
; EPILOGUE: [[SCALAR_PH]]:
62+
; EPILOGUE-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
63+
; EPILOGUE-NEXT: br label %[[LOOP:.*]]
64+
; EPILOGUE: [[LOOP]]:
65+
; EPILOGUE-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
66+
; EPILOGUE-NEXT: [[MUL_2:%.*]] = shl nsw i64 [[IV]], 1
67+
; EPILOGUE-NEXT: [[DATA_0:%.*]] = getelementptr inbounds i64, ptr [[DATA]], i64 [[MUL_2]]
68+
; EPILOGUE-NEXT: [[L_0:%.*]] = load i64, ptr [[DATA_0]], align 8
69+
; EPILOGUE-NEXT: store i64 [[L_0]], ptr [[DATA_0]], align 8
70+
; EPILOGUE-NEXT: [[ADD_1:%.*]] = or disjoint i64 [[MUL_2]], 1
71+
; EPILOGUE-NEXT: [[DATA_1:%.*]] = getelementptr inbounds i64, ptr [[DATA]], i64 [[ADD_1]]
72+
; EPILOGUE-NEXT: [[L_1:%.*]] = load i64, ptr [[DATA_1]], align 8
73+
; EPILOGUE-NEXT: store i64 [[L_1]], ptr [[DATA_1]], align 8
74+
; EPILOGUE-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
75+
; EPILOGUE-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], 100
76+
; EPILOGUE-NEXT: br i1 [[EC]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP3:![0-9]+]]
77+
; EPILOGUE: [[EXIT]]:
78+
; EPILOGUE-NEXT: ret void
79+
;
80+
entry:
81+
br label %loop
82+
83+
loop:
84+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
85+
%mul.2 = shl nsw i64 %iv, 1
86+
%data.0 = getelementptr inbounds i64, ptr %data, i64 %mul.2
87+
%l.0 = load i64, ptr %data.0, align 8
88+
store i64 %l.0, ptr %data.0, align 8
89+
%add.1 = or disjoint i64 %mul.2, 1
90+
%data.1 = getelementptr inbounds i64, ptr %data, i64 %add.1
91+
%l.1 = load i64, ptr %data.1, align 8
92+
store i64 %l.1, ptr %data.1, align 8
93+
%iv.next = add nuw nsw i64 %iv, 1
94+
%ec = icmp eq i64 %iv.next, 100
95+
br i1 %ec, label %exit, label %loop
96+
97+
exit:
98+
ret void
99+
}
100+
101+
102+
define void @load_store_interleave_group_i32(ptr noalias %data) {
103+
; CHECK-LABEL: define void @load_store_interleave_group_i32(
104+
; CHECK-SAME: ptr noalias [[DATA:%.*]]) #[[ATTR0]] {
105+
; CHECK-NEXT: [[ENTRY:.*:]]
106+
; CHECK-NEXT: br label %[[VECTOR_PH:.*]]
107+
; CHECK: [[VECTOR_PH]]:
108+
; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
109+
; CHECK: [[VECTOR_BODY]]:
110+
; CHECK-NEXT: [[EVL_BASED_IV:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_EVL_NEXT:%.*]], %[[VECTOR_BODY]] ]
111+
; CHECK-NEXT: [[AVL:%.*]] = phi i64 [ 100, %[[VECTOR_PH]] ], [ [[AVL_NEXT:%.*]], %[[VECTOR_BODY]] ]
112+
; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.experimental.get.vector.length.i64(i64 [[AVL]], i32 4, i1 true)
113+
; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i64 [[EVL_BASED_IV]], 2
114+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[DATA]], i64 [[TMP1]]
115+
; CHECK-NEXT: [[INTERLEAVE_EVL:%.*]] = mul nuw nsw i32 [[TMP0]], 4
116+
; CHECK-NEXT: [[WIDE_VP_LOAD:%.*]] = call <vscale x 16 x i32> @llvm.vp.load.nxv16i32.p0(ptr align 8 [[TMP2]], <vscale x 16 x i1> splat (i1 true), i32 [[INTERLEAVE_EVL]])
117+
; CHECK-NEXT: [[STRIDED_VEC:%.*]] = call { <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32> } @llvm.vector.deinterleave4.nxv16i32(<vscale x 16 x i32> [[WIDE_VP_LOAD]])
118+
; CHECK-NEXT: [[TMP3:%.*]] = extractvalue { <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32> } [[STRIDED_VEC]], 0
119+
; CHECK-NEXT: [[TMP4:%.*]] = extractvalue { <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32> } [[STRIDED_VEC]], 1
120+
; CHECK-NEXT: [[TMP7:%.*]] = extractvalue { <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32> } [[STRIDED_VEC]], 2
121+
; CHECK-NEXT: [[TMP8:%.*]] = extractvalue { <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32>, <vscale x 4 x i32> } [[STRIDED_VEC]], 3
122+
; CHECK-NEXT: [[INTERLEAVE_EVL1:%.*]] = mul nuw nsw i32 [[TMP0]], 4
123+
; CHECK-NEXT: [[INTERLEAVED_VEC:%.*]] = call <vscale x 16 x i32> @llvm.vector.interleave4.nxv16i32(<vscale x 4 x i32> [[TMP3]], <vscale x 4 x i32> [[TMP4]], <vscale x 4 x i32> [[TMP7]], <vscale x 4 x i32> [[TMP8]])
124+
; CHECK-NEXT: call void @llvm.vp.store.nxv16i32.p0(<vscale x 16 x i32> [[INTERLEAVED_VEC]], ptr align 8 [[TMP2]], <vscale x 16 x i1> splat (i1 true), i32 [[INTERLEAVE_EVL1]])
125+
; CHECK-NEXT: [[TMP5:%.*]] = zext i32 [[TMP0]] to i64
126+
; CHECK-NEXT: [[INDEX_EVL_NEXT]] = add nuw i64 [[TMP5]], [[EVL_BASED_IV]]
127+
; CHECK-NEXT: [[AVL_NEXT]] = sub nuw i64 [[AVL]], [[TMP5]]
128+
; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[AVL_NEXT]], 0
129+
; CHECK-NEXT: br i1 [[TMP6]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]
130+
; CHECK: [[MIDDLE_BLOCK]]:
131+
; CHECK-NEXT: br label %[[EXIT:.*]]
132+
; CHECK: [[EXIT]]:
133+
; CHECK-NEXT: ret void
134+
;
135+
; EPILOGUE-LABEL: define void @load_store_interleave_group_i32(
136+
; EPILOGUE-SAME: ptr noalias [[DATA:%.*]]) #[[ATTR0]] {
137+
; EPILOGUE-NEXT: [[ENTRY:.*]]:
138+
; EPILOGUE-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
139+
; EPILOGUE-NEXT: [[TMP1:%.*]] = shl nuw i64 [[TMP0]], 2
140+
; EPILOGUE-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 100, [[TMP1]]
141+
; EPILOGUE-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
142+
; EPILOGUE: [[VECTOR_PH]]:
143+
; EPILOGUE-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
144+
; EPILOGUE-NEXT: [[TMP3:%.*]] = mul nuw i64 [[TMP2]], 4
145+
; EPILOGUE-NEXT: [[N_MOD_VF:%.*]] = urem i64 100, [[TMP3]]
146+
; EPILOGUE-NEXT: [[N_VEC:%.*]] = sub i64 100, [[N_MOD_VF]]
147+
; EPILOGUE-NEXT: br label %[[VECTOR_BODY:.*]]
148+
; EPILOGUE: [[VECTOR_BODY]]:
149+
; EPILOGUE-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
150+
; EPILOGUE-NEXT: [[TMP4:%.*]] = shl nsw i64 [[INDEX]], 2
151+
; EPILOGUE-NEXT: [[TMP5:%.*]] = getelementptr inbounds i32, ptr [[DATA]], i64 [[TMP4]]
152+
; EPILOGUE-NEXT: [[WIDE_LOAD:%.*]] = load <vscale x 4 x i32>, ptr [[TMP5]], align 8
153+
; EPILOGUE-NEXT: store <vscale x 4 x i32> [[WIDE_LOAD]], ptr [[TMP5]], align 8
154+
; EPILOGUE-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP2]]
155+
; EPILOGUE-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
156+
; EPILOGUE-NEXT: br i1 [[TMP8]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]
157+
; EPILOGUE: [[MIDDLE_BLOCK]]:
158+
; EPILOGUE-NEXT: [[CMP_N:%.*]] = icmp eq i64 100, [[N_VEC]]
159+
; EPILOGUE-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]
160+
; EPILOGUE: [[SCALAR_PH]]:
161+
; EPILOGUE-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
162+
; EPILOGUE-NEXT: br label %[[LOOP:.*]]
163+
; EPILOGUE: [[LOOP]]:
164+
; EPILOGUE-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
165+
; EPILOGUE-NEXT: [[MUL_2:%.*]] = shl nsw i64 [[IV]], 2
166+
; EPILOGUE-NEXT: [[DATA_0:%.*]] = getelementptr inbounds i32, ptr [[DATA]], i64 [[MUL_2]]
167+
; EPILOGUE-NEXT: [[L_0:%.*]] = load i32, ptr [[DATA_0]], align 8
168+
; EPILOGUE-NEXT: store i32 [[L_0]], ptr [[DATA_0]], align 8
169+
; EPILOGUE-NEXT: [[ADD_1:%.*]] = or disjoint i64 [[MUL_2]], 1
170+
; EPILOGUE-NEXT: [[DATA_1:%.*]] = getelementptr inbounds i32, ptr [[DATA]], i64 [[ADD_1]]
171+
; EPILOGUE-NEXT: [[L_1:%.*]] = load i32, ptr [[DATA_1]], align 8
172+
; EPILOGUE-NEXT: store i32 [[L_1]], ptr [[DATA_1]], align 8
173+
; EPILOGUE-NEXT: [[ADD_2:%.*]] = add i64 [[MUL_2]], 2
174+
; EPILOGUE-NEXT: [[DATA_2:%.*]] = getelementptr inbounds i32, ptr [[DATA]], i64 [[ADD_2]]
175+
; EPILOGUE-NEXT: [[L_2:%.*]] = load i32, ptr [[DATA_2]], align 8
176+
; EPILOGUE-NEXT: store i32 [[L_2]], ptr [[DATA_2]], align 8
177+
; EPILOGUE-NEXT: [[ADD_3:%.*]] = add i64 [[MUL_2]], 3
178+
; EPILOGUE-NEXT: [[DATA_3:%.*]] = getelementptr inbounds i32, ptr [[DATA]], i64 [[ADD_3]]
179+
; EPILOGUE-NEXT: [[L_3:%.*]] = load i32, ptr [[DATA_3]], align 8
180+
; EPILOGUE-NEXT: store i32 [[L_3]], ptr [[DATA_3]], align 8
181+
; EPILOGUE-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
182+
; EPILOGUE-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], 100
183+
; EPILOGUE-NEXT: br i1 [[EC]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]
184+
; EPILOGUE: [[EXIT]]:
185+
; EPILOGUE-NEXT: ret void
186+
;
187+
entry:
188+
br label %loop
189+
190+
loop:
191+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
192+
%mul.4 = shl nsw i64 %iv, 2
193+
%data.0 = getelementptr inbounds i32, ptr %data, i64 %mul.4
194+
%l.0 = load i32, ptr %data.0, align 8
195+
store i32 %l.0, ptr %data.0, align 8
196+
%add.1 = or disjoint i64 %mul.4, 1
197+
%data.1 = getelementptr inbounds i32, ptr %data, i64 %add.1
198+
%l.1 = load i32, ptr %data.1, align 8
199+
store i32 %l.1, ptr %data.1, align 8
200+
%add.2 = add i64 %mul.4, 2
201+
%data.2 = getelementptr inbounds i32, ptr %data, i64 %add.2
202+
%l.2 = load i32, ptr %data.2, align 8
203+
store i32 %l.2, ptr %data.2, align 8
204+
%add.3 = add i64 %mul.4, 3
205+
%data.3 = getelementptr inbounds i32, ptr %data, i64 %add.3
206+
%l.3 = load i32, ptr %data.3, align 8
207+
store i32 %l.3, ptr %data.3, align 8
208+
%iv.next = add nuw nsw i64 %iv, 1
209+
%ec = icmp eq i64 %iv.next, 100
210+
br i1 %ec, label %exit, label %loop
211+
212+
exit:
213+
ret void
214+
}

0 commit comments

Comments
 (0)