1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -p loop-vectorize -mtriple aarch64 -mcpu=neoverse-v1 -S %s | FileCheck %s
4 ; Test case for https://github.com/llvm/llvm-project/issues/94328.
5 define void @sdiv_feeding_gep(ptr %dst, i32 %x, i64 %M, i64 %conv6, i64 %N) {
6 ; CHECK-LABEL: define void @sdiv_feeding_gep(
7 ; CHECK-SAME: ptr [[DST:%.*]], i32 [[X:%.*]], i64 [[M:%.*]], i64 [[CONV6:%.*]], i64 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
8 ; CHECK-NEXT: [[ENTRY:.*]]:
9 ; CHECK-NEXT: [[CONV61:%.*]] = zext i32 [[X]] to i64
10 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
11 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
12 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.umax.i64(i64 8, i64 [[TMP1]])
13 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[N]], [[TMP2]]
14 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label %[[VECTOR_SCEVCHECK:.*]]
15 ; CHECK: [[VECTOR_SCEVCHECK]]:
16 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[N]], -1
17 ; CHECK-NEXT: [[TMP4:%.*]] = trunc i64 [[TMP3]] to i32
18 ; CHECK-NEXT: [[TMP5:%.*]] = icmp slt i32 [[TMP4]], 0
19 ; CHECK-NEXT: [[TMP6:%.*]] = icmp ugt i64 [[TMP3]], 4294967295
20 ; CHECK-NEXT: [[TMP7:%.*]] = or i1 [[TMP5]], [[TMP6]]
21 ; CHECK-NEXT: br i1 [[TMP7]], label %[[SCALAR_PH]], label %[[VECTOR_PH:.*]]
22 ; CHECK: [[VECTOR_PH]]:
23 ; CHECK-NEXT: [[TMP8:%.*]] = call i64 @llvm.vscale.i64()
24 ; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP8]], 4
25 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N]], [[TMP9]]
26 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N]], [[N_MOD_VF]]
27 ; CHECK-NEXT: [[TMP10:%.*]] = call i64 @llvm.vscale.i64()
28 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP10]], 4
29 ; CHECK-NEXT: [[TMP18:%.*]] = sdiv i64 [[M]], [[CONV6]]
30 ; CHECK-NEXT: [[TMP20:%.*]] = trunc i64 [[TMP18]] to i32
31 ; CHECK-NEXT: [[TMP22:%.*]] = mul i64 [[TMP18]], [[CONV61]]
32 ; CHECK-NEXT: [[TMP28:%.*]] = mul i32 [[X]], [[TMP20]]
33 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
34 ; CHECK: [[VECTOR_BODY]]:
35 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
36 ; CHECK-NEXT: [[TMP12:%.*]] = add i64 [[INDEX]], 0
37 ; CHECK-NEXT: [[TMP24:%.*]] = sub i64 [[TMP12]], [[TMP22]]
38 ; CHECK-NEXT: [[TMP26:%.*]] = trunc i64 [[TMP24]] to i32
39 ; CHECK-NEXT: [[TMP30:%.*]] = add i32 [[TMP28]], [[TMP26]]
40 ; CHECK-NEXT: [[TMP32:%.*]] = sext i32 [[TMP30]] to i64
41 ; CHECK-NEXT: [[TMP34:%.*]] = getelementptr double, ptr [[DST]], i64 [[TMP32]]
42 ; CHECK-NEXT: [[TMP36:%.*]] = getelementptr double, ptr [[TMP34]], i32 0
43 ; CHECK-NEXT: [[TMP37:%.*]] = call i64 @llvm.vscale.i64()
44 ; CHECK-NEXT: [[TMP38:%.*]] = mul i64 [[TMP37]], 2
45 ; CHECK-NEXT: [[TMP39:%.*]] = getelementptr double, ptr [[TMP34]], i64 [[TMP38]]
46 ; CHECK-NEXT: store <vscale x 2 x double> zeroinitializer, ptr [[TMP36]], align 8
47 ; CHECK-NEXT: store <vscale x 2 x double> zeroinitializer, ptr [[TMP39]], align 8
48 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP11]]
49 ; CHECK-NEXT: [[TMP40:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
50 ; CHECK-NEXT: br i1 [[TMP40]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
51 ; CHECK: [[MIDDLE_BLOCK]]:
52 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[N]], [[N_VEC]]
53 ; CHECK-NEXT: br i1 [[CMP_N]], label %[[EXIT:.*]], label %[[SCALAR_PH]]
54 ; CHECK: [[SCALAR_PH]]:
55 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ], [ 0, %[[VECTOR_SCEVCHECK]] ]
56 ; CHECK-NEXT: br label %[[LOOP:.*]]
58 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
59 ; CHECK-NEXT: [[DIV18:%.*]] = sdiv i64 [[M]], [[CONV6]]
60 ; CHECK-NEXT: [[CONV20:%.*]] = trunc i64 [[DIV18]] to i32
61 ; CHECK-NEXT: [[MUL30:%.*]] = mul i64 [[DIV18]], [[CONV61]]
62 ; CHECK-NEXT: [[SUB31:%.*]] = sub i64 [[IV]], [[MUL30]]
63 ; CHECK-NEXT: [[CONV34:%.*]] = trunc i64 [[SUB31]] to i32
64 ; CHECK-NEXT: [[MUL35:%.*]] = mul i32 [[X]], [[CONV20]]
65 ; CHECK-NEXT: [[ADD36:%.*]] = add i32 [[MUL35]], [[CONV34]]
66 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[ADD36]] to i64
67 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[DST]], i64 [[IDXPROM]]
68 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP]], align 8
69 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
70 ; CHECK-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
71 ; CHECK-NEXT: br i1 [[EC]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP3:![0-9]+]]
73 ; CHECK-NEXT: ret void
76 %conv61 = zext i32 %x to i64
80 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
81 %div18 = sdiv i64 %M, %conv6
82 %conv20 = trunc i64 %div18 to i32
83 %mul30 = mul i64 %div18, %conv61
84 %sub31 = sub i64 %iv, %mul30
85 %conv34 = trunc i64 %sub31 to i32
86 %mul35 = mul i32 %x, %conv20
87 %add36 = add i32 %mul35, %conv34
88 %idxprom = sext i32 %add36 to i64
89 %gep = getelementptr double, ptr %dst, i64 %idxprom
90 store double 0.000000e+00, ptr %gep, align 8
91 %iv.next = add i64 %iv, 1
92 %ec = icmp eq i64 %iv.next, %N
93 br i1 %ec, label %exit, label %loop
99 define void @sdiv_feeding_gep_predicated(ptr %dst, i32 %x, i64 %M, i64 %conv6, i64 %N) {
100 ; CHECK-LABEL: define void @sdiv_feeding_gep_predicated(
101 ; CHECK-SAME: ptr [[DST:%.*]], i32 [[X:%.*]], i64 [[M:%.*]], i64 [[CONV6:%.*]], i64 [[N:%.*]]) #[[ATTR0]] {
102 ; CHECK-NEXT: [[ENTRY:.*]]:
103 ; CHECK-NEXT: [[CONV61:%.*]] = zext i32 [[X]] to i64
104 ; CHECK-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_SCEVCHECK:.*]]
105 ; CHECK: [[VECTOR_SCEVCHECK]]:
106 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N]], -1
107 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[TMP0]] to i32
108 ; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
109 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
110 ; CHECK-NEXT: [[TMP4:%.*]] = or i1 [[TMP2]], [[TMP3]]
111 ; CHECK-NEXT: br i1 [[TMP4]], label %[[SCALAR_PH]], label %[[VECTOR_PH:.*]]
112 ; CHECK: [[VECTOR_PH]]:
113 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
114 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 2
115 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[TMP6]], 1
116 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[N]], [[TMP7]]
117 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP6]]
118 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
119 ; CHECK-NEXT: [[TMP8:%.*]] = call i64 @llvm.vscale.i64()
120 ; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP8]], 2
121 ; CHECK-NEXT: [[TMP10:%.*]] = call i64 @llvm.vscale.i64()
122 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP10]], 2
123 ; CHECK-NEXT: [[TMP12:%.*]] = sub i64 [[N]], [[TMP11]]
124 ; CHECK-NEXT: [[TMP13:%.*]] = icmp ugt i64 [[N]], [[TMP11]]
125 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i64 [[TMP12]], i64 0
126 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 2 x i1> @llvm.get.active.lane.mask.nxv2i1.i64(i64 0, i64 [[N]])
127 ; CHECK-NEXT: [[TMP15:%.*]] = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
128 ; CHECK-NEXT: [[TMP16:%.*]] = add <vscale x 2 x i64> [[TMP15]], zeroinitializer
129 ; CHECK-NEXT: [[TMP17:%.*]] = mul <vscale x 2 x i64> [[TMP16]], splat (i64 1)
130 ; CHECK-NEXT: [[INDUCTION:%.*]] = add <vscale x 2 x i64> zeroinitializer, [[TMP17]]
131 ; CHECK-NEXT: [[TMP20:%.*]] = mul i64 1, [[TMP9]]
132 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP20]], i64 0
133 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[DOTSPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
134 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[M]], i64 0
135 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
136 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT1:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[CONV6]], i64 0
137 ; CHECK-NEXT: [[BROADCAST_SPLAT2:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT1]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
138 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
139 ; CHECK: [[VECTOR_BODY]]:
140 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
141 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 2 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], %[[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], %[[VECTOR_BODY]] ]
142 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <vscale x 2 x i64> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]
143 ; CHECK-NEXT: [[TMP21:%.*]] = add i64 [[INDEX]], 0
144 ; CHECK-NEXT: [[TMP22:%.*]] = icmp ule <vscale x 2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]]
145 ; CHECK-NEXT: [[TMP23:%.*]] = select <vscale x 2 x i1> [[ACTIVE_LANE_MASK]], <vscale x 2 x i1> [[TMP22]], <vscale x 2 x i1> zeroinitializer
146 ; CHECK-NEXT: [[TMP24:%.*]] = select <vscale x 2 x i1> [[TMP23]], <vscale x 2 x i64> [[BROADCAST_SPLAT2]], <vscale x 2 x i64> splat (i64 1)
147 ; CHECK-NEXT: [[TMP25:%.*]] = sdiv <vscale x 2 x i64> [[BROADCAST_SPLAT]], [[TMP24]]
148 ; CHECK-NEXT: [[TMP26:%.*]] = extractelement <vscale x 2 x i64> [[TMP25]], i32 0
149 ; CHECK-NEXT: [[TMP27:%.*]] = trunc i64 [[TMP26]] to i32
150 ; CHECK-NEXT: [[TMP28:%.*]] = mul i64 [[TMP26]], [[CONV61]]
151 ; CHECK-NEXT: [[TMP29:%.*]] = sub i64 [[TMP21]], [[TMP28]]
152 ; CHECK-NEXT: [[TMP30:%.*]] = trunc i64 [[TMP29]] to i32
153 ; CHECK-NEXT: [[TMP31:%.*]] = mul i32 [[X]], [[TMP27]]
154 ; CHECK-NEXT: [[TMP32:%.*]] = add i32 [[TMP31]], [[TMP30]]
155 ; CHECK-NEXT: [[TMP33:%.*]] = sext i32 [[TMP32]] to i64
156 ; CHECK-NEXT: [[TMP34:%.*]] = getelementptr double, ptr [[DST]], i64 [[TMP33]]
157 ; CHECK-NEXT: [[TMP35:%.*]] = getelementptr double, ptr [[TMP34]], i32 0
158 ; CHECK-NEXT: call void @llvm.masked.store.nxv2f64.p0(<vscale x 2 x double> zeroinitializer, ptr [[TMP35]], i32 8, <vscale x 2 x i1> [[TMP23]])
159 ; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], [[TMP9]]
160 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 2 x i1> @llvm.get.active.lane.mask.nxv2i1.i64(i64 [[INDEX]], i64 [[TMP14]])
161 ; CHECK-NEXT: [[TMP36:%.*]] = xor <vscale x 2 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
162 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <vscale x 2 x i64> [[VEC_IND]], [[DOTSPLAT]]
163 ; CHECK-NEXT: [[TMP37:%.*]] = extractelement <vscale x 2 x i1> [[TMP36]], i32 0
164 ; CHECK-NEXT: br i1 [[TMP37]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]
165 ; CHECK: [[MIDDLE_BLOCK]]:
166 ; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[SCALAR_PH]]
167 ; CHECK: [[SCALAR_PH]]:
168 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ], [ 0, %[[VECTOR_SCEVCHECK]] ]
169 ; CHECK-NEXT: br label %[[LOOP:.*]]
171 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
172 ; CHECK-NEXT: [[C:%.*]] = icmp ule i64 [[IV]], [[M]]
173 ; CHECK-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[LOOP_LATCH]]
175 ; CHECK-NEXT: [[DIV18:%.*]] = sdiv i64 [[M]], [[CONV6]]
176 ; CHECK-NEXT: [[CONV20:%.*]] = trunc i64 [[DIV18]] to i32
177 ; CHECK-NEXT: [[MUL30:%.*]] = mul i64 [[DIV18]], [[CONV61]]
178 ; CHECK-NEXT: [[SUB31:%.*]] = sub i64 [[IV]], [[MUL30]]
179 ; CHECK-NEXT: [[CONV34:%.*]] = trunc i64 [[SUB31]] to i32
180 ; CHECK-NEXT: [[MUL35:%.*]] = mul i32 [[X]], [[CONV20]]
181 ; CHECK-NEXT: [[ADD36:%.*]] = add i32 [[MUL35]], [[CONV34]]
182 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[ADD36]] to i64
183 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr double, ptr [[DST]], i64 [[IDXPROM]]
184 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP]], align 8
185 ; CHECK-NEXT: br label %[[LOOP_LATCH]]
186 ; CHECK: [[LOOP_LATCH]]:
187 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
188 ; CHECK-NEXT: [[EC:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
189 ; CHECK-NEXT: br i1 [[EC]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP5:![0-9]+]]
191 ; CHECK-NEXT: ret void
194 %conv61 = zext i32 %x to i64
198 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
199 %c = icmp ule i64 %iv, %M
200 br i1 %c, label %then, label %loop.latch
203 %div18 = sdiv i64 %M, %conv6
204 %conv20 = trunc i64 %div18 to i32
205 %mul30 = mul i64 %div18, %conv61
206 %sub31 = sub i64 %iv, %mul30
207 %conv34 = trunc i64 %sub31 to i32
208 %mul35 = mul i32 %x, %conv20
209 %add36 = add i32 %mul35, %conv34
210 %idxprom = sext i32 %add36 to i64
211 %gep = getelementptr double, ptr %dst, i64 %idxprom
212 store double 0.000000e+00, ptr %gep, align 8
216 %iv.next = add i64 %iv, 1
217 %ec = icmp eq i64 %iv.next, %N
218 br i1 %ec, label %exit, label %loop
224 ; Test case for https://github.com/llvm/llvm-project/issues/80416.
225 define void @udiv_urem_feeding_gep(i64 %x, ptr %dst, i64 %N) {
226 ; CHECK-LABEL: define void @udiv_urem_feeding_gep(
227 ; CHECK-SAME: i64 [[X:%.*]], ptr [[DST:%.*]], i64 [[N:%.*]]) #[[ATTR0]] {
228 ; CHECK-NEXT: [[ENTRY:.*]]:
229 ; CHECK-NEXT: [[MUL_1_I:%.*]] = mul i64 [[X]], [[X]]
230 ; CHECK-NEXT: [[MUL_2_I:%.*]] = mul i64 [[MUL_1_I]], [[X]]
231 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N]], 1
232 ; CHECK-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_SCEVCHECK:.*]]
233 ; CHECK: [[VECTOR_SCEVCHECK]]:
234 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[N]] to i32
235 ; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
236 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ugt i64 [[N]], 4294967295
237 ; CHECK-NEXT: [[TMP4:%.*]] = or i1 [[TMP2]], [[TMP3]]
238 ; CHECK-NEXT: br i1 [[TMP4]], label %[[SCALAR_PH]], label %[[VECTOR_PH:.*]]
239 ; CHECK: [[VECTOR_PH]]:
240 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
241 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 2
242 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[TMP6]], 1
243 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[TMP0]], [[TMP7]]
244 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP6]]
245 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
246 ; CHECK-NEXT: [[TMP8:%.*]] = call i64 @llvm.vscale.i64()
247 ; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP8]], 2
248 ; CHECK-NEXT: [[TMP10:%.*]] = call i64 @llvm.vscale.i64()
249 ; CHECK-NEXT: [[TMP11:%.*]] = mul i64 [[TMP10]], 2
250 ; CHECK-NEXT: [[TMP12:%.*]] = sub i64 [[TMP0]], [[TMP11]]
251 ; CHECK-NEXT: [[TMP13:%.*]] = icmp ugt i64 [[TMP0]], [[TMP11]]
252 ; CHECK-NEXT: [[TMP14:%.*]] = select i1 [[TMP13]], i64 [[TMP12]], i64 0
253 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 2 x i1> @llvm.get.active.lane.mask.nxv2i1.i64(i64 0, i64 [[TMP0]])
254 ; CHECK-NEXT: [[TMP15:%.*]] = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
255 ; CHECK-NEXT: [[TMP16:%.*]] = add <vscale x 2 x i64> [[TMP15]], zeroinitializer
256 ; CHECK-NEXT: [[TMP17:%.*]] = mul <vscale x 2 x i64> [[TMP16]], splat (i64 1)
257 ; CHECK-NEXT: [[INDUCTION:%.*]] = add <vscale x 2 x i64> zeroinitializer, [[TMP17]]
258 ; CHECK-NEXT: [[TMP20:%.*]] = mul i64 1, [[TMP9]]
259 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP20]], i64 0
260 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
261 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT3:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[MUL_2_I]], i64 0
262 ; CHECK-NEXT: [[BROADCAST_SPLAT4:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT3]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
263 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
264 ; CHECK: [[VECTOR_BODY]]:
265 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
266 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 2 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], %[[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], %[[VECTOR_BODY]] ]
267 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <vscale x 2 x i64> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]
268 ; CHECK-NEXT: [[TMP21:%.*]] = add i64 [[INDEX]], 0
269 ; CHECK-NEXT: [[TMP23:%.*]] = udiv <vscale x 2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT4]]
270 ; CHECK-NEXT: [[TMP24:%.*]] = urem i64 [[TMP21]], [[MUL_2_I]]
271 ; CHECK-NEXT: [[TMP25:%.*]] = udiv i64 [[TMP24]], [[MUL_1_I]]
272 ; CHECK-NEXT: [[TMP26:%.*]] = urem i64 [[TMP24]], [[MUL_1_I]]
273 ; CHECK-NEXT: [[TMP27:%.*]] = udiv i64 [[TMP26]], [[X]]
274 ; CHECK-NEXT: [[TMP28:%.*]] = urem i64 [[TMP26]], [[X]]
275 ; CHECK-NEXT: [[TMP29:%.*]] = extractelement <vscale x 2 x i64> [[TMP23]], i32 0
276 ; CHECK-NEXT: [[TMP30:%.*]] = mul i64 [[X]], [[TMP29]]
277 ; CHECK-NEXT: [[TMP31:%.*]] = add i64 [[TMP30]], [[TMP25]]
278 ; CHECK-NEXT: [[TMP32:%.*]] = mul i64 [[TMP31]], [[X]]
279 ; CHECK-NEXT: [[TMP33:%.*]] = add i64 [[TMP32]], [[TMP27]]
280 ; CHECK-NEXT: [[TMP34:%.*]] = mul i64 [[TMP33]], [[X]]
281 ; CHECK-NEXT: [[TMP35:%.*]] = add i64 [[TMP34]], [[TMP28]]
282 ; CHECK-NEXT: [[TMP36:%.*]] = shl i64 [[TMP35]], 32
283 ; CHECK-NEXT: [[TMP37:%.*]] = ashr i64 [[TMP36]], 32
284 ; CHECK-NEXT: [[TMP38:%.*]] = getelementptr i64, ptr [[DST]], i64 [[TMP37]]
285 ; CHECK-NEXT: [[TMP39:%.*]] = getelementptr i64, ptr [[TMP38]], i32 0
286 ; CHECK-NEXT: call void @llvm.masked.store.nxv2i64.p0(<vscale x 2 x i64> [[TMP23]], ptr [[TMP39]], i32 4, <vscale x 2 x i1> [[ACTIVE_LANE_MASK]])
287 ; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], [[TMP9]]
288 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 2 x i1> @llvm.get.active.lane.mask.nxv2i1.i64(i64 [[INDEX]], i64 [[TMP14]])
289 ; CHECK-NEXT: [[TMP47:%.*]] = xor <vscale x 2 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
290 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <vscale x 2 x i64> [[VEC_IND]], [[BROADCAST_SPLAT]]
291 ; CHECK-NEXT: [[TMP48:%.*]] = extractelement <vscale x 2 x i1> [[TMP47]], i32 0
292 ; CHECK-NEXT: br i1 [[TMP48]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
293 ; CHECK: [[MIDDLE_BLOCK]]:
294 ; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[SCALAR_PH]]
295 ; CHECK: [[SCALAR_PH]]:
296 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ], [ 0, %[[VECTOR_SCEVCHECK]] ]
297 ; CHECK-NEXT: br label %[[LOOP:.*]]
299 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP]] ]
300 ; CHECK-NEXT: [[DIV_I:%.*]] = udiv i64 [[IV]], [[MUL_2_I]]
301 ; CHECK-NEXT: [[REM_I:%.*]] = urem i64 [[IV]], [[MUL_2_I]]
302 ; CHECK-NEXT: [[DIV_1_I:%.*]] = udiv i64 [[REM_I]], [[MUL_1_I]]
303 ; CHECK-NEXT: [[REM_1_I:%.*]] = urem i64 [[REM_I]], [[MUL_1_I]]
304 ; CHECK-NEXT: [[DIV_2_I:%.*]] = udiv i64 [[REM_1_I]], [[X]]
305 ; CHECK-NEXT: [[REM_2_I:%.*]] = urem i64 [[REM_1_I]], [[X]]
306 ; CHECK-NEXT: [[MUL_I:%.*]] = mul i64 [[X]], [[DIV_I]]
307 ; CHECK-NEXT: [[ADD_I:%.*]] = add i64 [[MUL_I]], [[DIV_1_I]]
308 ; CHECK-NEXT: [[MUL_1_I9:%.*]] = mul i64 [[ADD_I]], [[X]]
309 ; CHECK-NEXT: [[ADD_1_I:%.*]] = add i64 [[MUL_1_I9]], [[DIV_2_I]]
310 ; CHECK-NEXT: [[MUL_2_I11:%.*]] = mul i64 [[ADD_1_I]], [[X]]
311 ; CHECK-NEXT: [[ADD_2_I:%.*]] = add i64 [[MUL_2_I11]], [[REM_2_I]]
312 ; CHECK-NEXT: [[SEXT_I:%.*]] = shl i64 [[ADD_2_I]], 32
313 ; CHECK-NEXT: [[CONV6_I:%.*]] = ashr i64 [[SEXT_I]], 32
314 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i64, ptr [[DST]], i64 [[CONV6_I]]
315 ; CHECK-NEXT: store i64 [[DIV_I]], ptr [[GEP]], align 4
316 ; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1
317 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[IV]], [[N]]
318 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label %[[EXIT]], label %[[LOOP]], !llvm.loop [[LOOP7:![0-9]+]]
320 ; CHECK-NEXT: ret void
323 %mul.1.i = mul i64 %x, %x
324 %mul.2.i = mul i64 %mul.1.i, %x
328 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
329 %div.i = udiv i64 %iv, %mul.2.i
330 %rem.i = urem i64 %iv, %mul.2.i
331 %div.1.i = udiv i64 %rem.i, %mul.1.i
332 %rem.1.i = urem i64 %rem.i, %mul.1.i
333 %div.2.i = udiv i64 %rem.1.i, %x
334 %rem.2.i = urem i64 %rem.1.i, %x
335 %mul.i = mul i64 %x, %div.i
336 %add.i = add i64 %mul.i, %div.1.i
337 %mul.1.i9 = mul i64 %add.i, %x
338 %add.1.i = add i64 %mul.1.i9, %div.2.i
339 %mul.2.i11 = mul i64 %add.1.i, %x
340 %add.2.i = add i64 %mul.2.i11, %rem.2.i
341 %sext.i = shl i64 %add.2.i, 32
342 %conv6.i = ashr i64 %sext.i, 32
343 %gep = getelementptr i64, ptr %dst, i64 %conv6.i
344 store i64 %div.i, ptr %gep, align 4
345 %iv.next = add i64 %iv, 1
346 %exitcond.not = icmp eq i64 %iv, %N
347 br i1 %exitcond.not, label %exit, label %loop
354 ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}
355 ; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1}
356 ; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"}
357 ; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META1]]}
358 ; CHECK: [[LOOP4]] = distinct !{[[LOOP4]], [[META1]], [[META2]]}
359 ; CHECK: [[LOOP5]] = distinct !{[[LOOP5]], [[META1]]}
360 ; CHECK: [[LOOP6]] = distinct !{[[LOOP6]], [[META1]], [[META2]]}
361 ; CHECK: [[LOOP7]] = distinct !{[[LOOP7]], [[META1]]}