1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -hints-allow-reordering=false -passes=loop-vectorize -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue < %s | FileCheck %s
4 target triple = "aarch64-unknown-linux-gnu"
7 define void @simple_memset(i32 %val, ptr %ptr, i64 %n) #0 {
8 ; CHECK-LABEL: @simple_memset(
10 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
11 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
13 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
14 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
15 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
16 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[UMAX]], [[TMP2]]
17 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
18 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
19 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
20 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
21 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
22 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
23 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[UMAX]], [[TMP6]]
24 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[UMAX]], [[TMP6]]
25 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
26 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[UMAX]])
27 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[VAL:%.*]], i64 0
28 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[BROADCAST_SPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
29 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
31 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
32 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
33 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX1]], 0
34 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr i32, ptr [[PTR:%.*]], i64 [[TMP10]]
35 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, ptr [[TMP11]], i32 0
36 ; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> [[BROADCAST_SPLAT]], ptr [[TMP12]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
37 ; CHECK-NEXT: [[INDEX_NEXT2]] = add i64 [[INDEX1]], [[TMP4]]
38 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP9]])
39 ; CHECK-NEXT: [[TMP13:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
40 ; CHECK-NEXT: [[TMP14:%.*]] = extractelement <vscale x 4 x i1> [[TMP13]], i32 0
41 ; CHECK-NEXT: br i1 [[TMP14]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
42 ; CHECK: middle.block:
43 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
45 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
46 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
48 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
49 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[PTR]], i64 [[INDEX]]
50 ; CHECK-NEXT: store i32 [[VAL]], ptr [[GEP]], align 4
51 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
52 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
53 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP3:![0-9]+]]
54 ; CHECK: while.end.loopexit:
55 ; CHECK-NEXT: ret void
60 while.body: ; preds = %while.body, %entry
61 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
62 %gep = getelementptr i32, ptr %ptr, i64 %index
63 store i32 %val, ptr %gep
64 %index.next = add nsw i64 %index, 1
65 %cmp10 = icmp ult i64 %index.next, %n
66 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
68 while.end.loopexit: ; preds = %while.body
73 define void @simple_memset_v4i32(i32 %val, ptr %ptr, i64 %n) #0 {
74 ; CHECK-LABEL: @simple_memset_v4i32(
76 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
77 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
79 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[UMAX]], 3
80 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], 4
81 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
82 ; CHECK-NEXT: [[TMP0:%.*]] = sub i64 [[UMAX]], 4
83 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i64 [[UMAX]], 4
84 ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i64 [[TMP0]], i64 0
85 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i64(i64 0, i64 [[UMAX]])
86 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> poison, i32 [[VAL:%.*]], i64 0
87 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> poison, <4 x i32> zeroinitializer
88 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
90 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
91 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
92 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[INDEX1]], 0
93 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i32, ptr [[PTR:%.*]], i64 [[TMP3]]
94 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i32, ptr [[TMP4]], i32 0
95 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[BROADCAST_SPLAT]], ptr [[TMP5]], i32 4, <4 x i1> [[ACTIVE_LANE_MASK]])
96 ; CHECK-NEXT: [[INDEX_NEXT2]] = add i64 [[INDEX1]], 4
97 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i64(i64 [[INDEX1]], i64 [[TMP2]])
98 ; CHECK-NEXT: [[TMP6:%.*]] = xor <4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
99 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i1> [[TMP6]], i32 0
100 ; CHECK-NEXT: br i1 [[TMP7]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]
101 ; CHECK: middle.block:
102 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
104 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
105 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
107 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
108 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[PTR]], i64 [[INDEX]]
109 ; CHECK-NEXT: store i32 [[VAL]], ptr [[GEP]], align 4
110 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
111 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
112 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP5:![0-9]+]]
113 ; CHECK: while.end.loopexit:
114 ; CHECK-NEXT: ret void
119 while.body: ; preds = %while.body, %entry
120 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
121 %gep = getelementptr i32, ptr %ptr, i64 %index
122 store i32 %val, ptr %gep
123 %index.next = add nsw i64 %index, 1
124 %cmp10 = icmp ult i64 %index.next, %n
125 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !3
127 while.end.loopexit: ; preds = %while.body
132 define void @simple_memcpy(ptr noalias %dst, ptr noalias %src, i64 %n) #0 {
133 ; CHECK-LABEL: @simple_memcpy(
135 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
136 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
138 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
139 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
140 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
141 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[UMAX]], [[TMP2]]
142 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
143 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
144 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
145 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
146 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
147 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
148 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[UMAX]], [[TMP6]]
149 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[UMAX]], [[TMP6]]
150 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
151 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[UMAX]])
152 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
153 ; CHECK: vector.body:
154 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
155 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
156 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX1]], 0
157 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr i32, ptr [[SRC:%.*]], i64 [[TMP10]]
158 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, ptr [[TMP11]], i32 0
159 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[TMP12]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
160 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr i32, ptr [[DST:%.*]], i64 [[TMP10]]
161 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr i32, ptr [[TMP13]], i32 0
162 ; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> [[WIDE_MASKED_LOAD]], ptr [[TMP14]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
163 ; CHECK-NEXT: [[INDEX_NEXT2]] = add i64 [[INDEX1]], [[TMP4]]
164 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP9]])
165 ; CHECK-NEXT: [[TMP15:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
166 ; CHECK-NEXT: [[TMP16:%.*]] = extractelement <vscale x 4 x i1> [[TMP15]], i32 0
167 ; CHECK-NEXT: br i1 [[TMP16]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
168 ; CHECK: middle.block:
169 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
171 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
172 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
174 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
175 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[SRC]], i64 [[INDEX]]
176 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[GEP1]], align 4
177 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[DST]], i64 [[INDEX]]
178 ; CHECK-NEXT: store i32 [[VAL]], ptr [[GEP2]], align 4
179 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
180 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
181 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP7:![0-9]+]]
182 ; CHECK: while.end.loopexit:
183 ; CHECK-NEXT: ret void
188 while.body: ; preds = %while.body, %entry
189 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
190 %gep1 = getelementptr i32, ptr %src, i64 %index
191 %val = load i32, ptr %gep1
192 %gep2 = getelementptr i32, ptr %dst, i64 %index
193 store i32 %val, ptr %gep2
194 %index.next = add nsw i64 %index, 1
195 %cmp10 = icmp ult i64 %index.next, %n
196 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
198 while.end.loopexit: ; preds = %while.body
203 define void @copy_stride4(ptr noalias %dst, ptr noalias %src, i64 %n) #0 {
204 ; CHECK-LABEL: @copy_stride4(
206 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 4)
207 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[UMAX]], -1
208 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 2
209 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
210 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
212 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
213 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
214 ; CHECK-NEXT: [[TMP5:%.*]] = sub i64 [[TMP4]], 1
215 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[TMP2]], [[TMP5]]
216 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP4]]
217 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
218 ; CHECK-NEXT: [[IND_END:%.*]] = mul i64 [[N_VEC]], 4
219 ; CHECK-NEXT: [[TMP6:%.*]] = call i64 @llvm.vscale.i64()
220 ; CHECK-NEXT: [[TMP7:%.*]] = mul i64 [[TMP6]], 4
221 ; CHECK-NEXT: [[TMP8:%.*]] = call i64 @llvm.vscale.i64()
222 ; CHECK-NEXT: [[TMP9:%.*]] = mul i64 [[TMP8]], 4
223 ; CHECK-NEXT: [[TMP10:%.*]] = sub i64 [[TMP2]], [[TMP9]]
224 ; CHECK-NEXT: [[TMP11:%.*]] = icmp ugt i64 [[TMP2]], [[TMP9]]
225 ; CHECK-NEXT: [[TMP12:%.*]] = select i1 [[TMP11]], i64 [[TMP10]], i64 0
226 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[TMP2]])
227 ; CHECK-NEXT: [[TMP13:%.*]] = call <vscale x 4 x i64> @llvm.stepvector.nxv4i64()
228 ; CHECK-NEXT: [[TMP14:%.*]] = add <vscale x 4 x i64> [[TMP13]], zeroinitializer
229 ; CHECK-NEXT: [[TMP15:%.*]] = mul <vscale x 4 x i64> [[TMP14]], splat (i64 4)
230 ; CHECK-NEXT: [[INDUCTION:%.*]] = add <vscale x 4 x i64> zeroinitializer, [[TMP15]]
231 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 4, [[TMP7]]
232 ; CHECK-NEXT: [[DOTSPLATINSERT:%.*]] = insertelement <vscale x 4 x i64> poison, i64 [[TMP18]], i64 0
233 ; CHECK-NEXT: [[DOTSPLAT:%.*]] = shufflevector <vscale x 4 x i64> [[DOTSPLATINSERT]], <vscale x 4 x i64> poison, <vscale x 4 x i32> zeroinitializer
234 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
235 ; CHECK: vector.body:
236 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
237 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
238 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <vscale x 4 x i64> [ [[INDUCTION]], [[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], [[VECTOR_BODY]] ]
239 ; CHECK-NEXT: [[TMP19:%.*]] = getelementptr i32, ptr [[SRC:%.*]], <vscale x 4 x i64> [[VEC_IND]]
240 ; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32.nxv4p0(<vscale x 4 x ptr> [[TMP19]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
241 ; CHECK-NEXT: [[TMP20:%.*]] = getelementptr i32, ptr [[DST:%.*]], <vscale x 4 x i64> [[VEC_IND]]
242 ; CHECK-NEXT: call void @llvm.masked.scatter.nxv4i32.nxv4p0(<vscale x 4 x i32> [[WIDE_MASKED_GATHER]], <vscale x 4 x ptr> [[TMP20]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
243 ; CHECK-NEXT: [[INDEX_NEXT2]] = add i64 [[INDEX1]], [[TMP7]]
244 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP12]])
245 ; CHECK-NEXT: [[TMP21:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
246 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <vscale x 4 x i64> [[VEC_IND]], [[DOTSPLAT]]
247 ; CHECK-NEXT: [[TMP22:%.*]] = extractelement <vscale x 4 x i1> [[TMP21]], i32 0
248 ; CHECK-NEXT: br i1 [[TMP22]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]]
249 ; CHECK: middle.block:
250 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
252 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
253 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
255 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
256 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[SRC]], i64 [[INDEX]]
257 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[GEP1]], align 4
258 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[DST]], i64 [[INDEX]]
259 ; CHECK-NEXT: store i32 [[VAL]], ptr [[GEP2]], align 4
260 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 4
261 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
262 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP9:![0-9]+]]
263 ; CHECK: while.end.loopexit:
264 ; CHECK-NEXT: ret void
269 while.body: ; preds = %while.body, %entry
270 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
271 %gep1 = getelementptr i32, ptr %src, i64 %index
272 %val = load i32, ptr %gep1
273 %gep2 = getelementptr i32, ptr %dst, i64 %index
274 store i32 %val, ptr %gep2
275 %index.next = add nsw i64 %index, 4
276 %cmp10 = icmp ult i64 %index.next, %n
277 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
279 while.end.loopexit: ; preds = %while.body
284 define void @simple_gather_scatter(ptr noalias %dst, ptr noalias %src, ptr noalias %ind, i64 %n) #0 {
285 ; CHECK-LABEL: @simple_gather_scatter(
287 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
288 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
290 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
291 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
292 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
293 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[UMAX]], [[TMP2]]
294 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
295 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
296 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
297 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
298 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
299 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
300 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[UMAX]], [[TMP6]]
301 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[UMAX]], [[TMP6]]
302 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
303 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[UMAX]])
304 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
305 ; CHECK: vector.body:
306 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
307 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
308 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX1]], 0
309 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr i32, ptr [[IND:%.*]], i64 [[TMP10]]
310 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, ptr [[TMP11]], i32 0
311 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[TMP12]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
312 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr i32, ptr [[SRC:%.*]], <vscale x 4 x i32> [[WIDE_MASKED_LOAD]]
313 ; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32.nxv4p0(<vscale x 4 x ptr> [[TMP13]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
314 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr i32, ptr [[DST:%.*]], <vscale x 4 x i32> [[WIDE_MASKED_LOAD]]
315 ; CHECK-NEXT: call void @llvm.masked.scatter.nxv4i32.nxv4p0(<vscale x 4 x i32> [[WIDE_MASKED_GATHER]], <vscale x 4 x ptr> [[TMP14]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
316 ; CHECK-NEXT: [[INDEX_NEXT2]] = add i64 [[INDEX1]], [[TMP4]]
317 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP9]])
318 ; CHECK-NEXT: [[TMP15:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
319 ; CHECK-NEXT: [[TMP16:%.*]] = extractelement <vscale x 4 x i1> [[TMP15]], i32 0
320 ; CHECK-NEXT: br i1 [[TMP16]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP10:![0-9]+]]
321 ; CHECK: middle.block:
322 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
324 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
325 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
327 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
328 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[IND]], i64 [[INDEX]]
329 ; CHECK-NEXT: [[IND_VAL:%.*]] = load i32, ptr [[GEP1]], align 4
330 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[SRC]], i32 [[IND_VAL]]
331 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[GEP2]], align 4
332 ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i32, ptr [[DST]], i32 [[IND_VAL]]
333 ; CHECK-NEXT: store i32 [[VAL]], ptr [[GEP3]], align 4
334 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
335 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
336 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP11:![0-9]+]]
337 ; CHECK: while.end.loopexit:
338 ; CHECK-NEXT: ret void
343 while.body: ; preds = %while.body, %entry
344 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
345 %gep1 = getelementptr i32, ptr %ind, i64 %index
346 %ind_val = load i32, ptr %gep1
347 %gep2 = getelementptr i32, ptr %src, i32 %ind_val
348 %val = load i32, ptr %gep2
349 %gep3 = getelementptr i32, ptr %dst, i32 %ind_val
350 store i32 %val, ptr %gep3
351 %index.next = add nsw i64 %index, 1
352 %cmp10 = icmp ult i64 %index.next, %n
353 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
355 while.end.loopexit: ; preds = %while.body
360 ; The original loop had an unconditional uniform load. Let's make sure
361 ; we don't artificially create new predicated blocks for the load.
362 define void @uniform_load(ptr noalias %dst, ptr noalias readonly %src, i64 %n) #0 {
363 ; CHECK-LABEL: @uniform_load(
365 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
367 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
368 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
369 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
370 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[N:%.*]], [[TMP2]]
371 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
372 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
373 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
374 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
375 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
376 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
377 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[N]], [[TMP6]]
378 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[N]], [[TMP6]]
379 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
380 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[N]])
381 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
382 ; CHECK: vector.body:
383 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
384 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
385 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX]], 0
386 ; CHECK-NEXT: [[TMP11:%.*]] = load i32, ptr [[SRC:%.*]], align 4
387 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[TMP11]], i64 0
388 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[BROADCAST_SPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
389 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds i32, ptr [[DST:%.*]], i64 [[TMP10]]
390 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds i32, ptr [[TMP12]], i32 0
391 ; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> [[BROADCAST_SPLAT]], ptr [[TMP13]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
392 ; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], [[TMP4]]
393 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX]], i64 [[TMP9]])
394 ; CHECK-NEXT: [[TMP14:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
395 ; CHECK-NEXT: [[TMP15:%.*]] = extractelement <vscale x 4 x i1> [[TMP14]], i32 0
396 ; CHECK-NEXT: br i1 [[TMP15]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP12:![0-9]+]]
397 ; CHECK: middle.block:
398 ; CHECK-NEXT: br i1 true, label [[FOR_END:%.*]], label [[SCALAR_PH]]
400 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
401 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
403 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
404 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[SRC]], align 4
405 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DST]], i64 [[INDVARS_IV]]
406 ; CHECK-NEXT: store i32 [[VAL]], ptr [[ARRAYIDX]], align 4
407 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
408 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N]]
409 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END]], label [[FOR_BODY]], !llvm.loop [[LOOP13:![0-9]+]]
411 ; CHECK-NEXT: ret void
417 for.body: ; preds = %entry, %for.body
418 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
419 %val = load i32, ptr %src, align 4
420 %arrayidx = getelementptr inbounds i32, ptr %dst, i64 %indvars.iv
421 store i32 %val, ptr %arrayidx, align 4
422 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
423 %exitcond.not = icmp eq i64 %indvars.iv.next, %n
424 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0
426 for.end: ; preds = %for.body, %entry
431 ; The original loop had a conditional uniform load. In this case we actually
432 ; do need to perform conditional loads and so we end up using a gather instead.
433 ; However, we at least ensure the mask is the overlap of the loop predicate
434 ; and the original condition.
435 define void @cond_uniform_load(ptr noalias %dst, ptr noalias readonly %src, ptr noalias readonly %cond, i64 %n) #0 {
436 ; CHECK-LABEL: @cond_uniform_load(
438 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
440 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
441 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
442 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
443 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[N:%.*]], [[TMP2]]
444 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
445 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
446 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
447 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
448 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
449 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
450 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[N]], [[TMP6]]
451 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[N]], [[TMP6]]
452 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
453 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[N]])
454 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x ptr> poison, ptr [[SRC:%.*]], i64 0
455 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x ptr> [[BROADCAST_SPLATINSERT]], <vscale x 4 x ptr> poison, <vscale x 4 x i32> zeroinitializer
456 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
457 ; CHECK: vector.body:
458 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
459 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
460 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX1]], 0
461 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds i32, ptr [[COND:%.*]], i64 [[TMP10]]
462 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds i32, ptr [[TMP11]], i32 0
463 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[TMP12]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
464 ; CHECK-NEXT: [[TMP13:%.*]] = icmp eq <vscale x 4 x i32> [[WIDE_MASKED_LOAD]], zeroinitializer
465 ; CHECK-NEXT: [[TMP14:%.*]] = xor <vscale x 4 x i1> [[TMP13]], splat (i1 true)
466 ; CHECK-NEXT: [[TMP15:%.*]] = select <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i1> [[TMP14]], <vscale x 4 x i1> zeroinitializer
467 ; CHECK-NEXT: [[WIDE_MASKED_GATHER:%.*]] = call <vscale x 4 x i32> @llvm.masked.gather.nxv4i32.nxv4p0(<vscale x 4 x ptr> [[BROADCAST_SPLAT]], i32 4, <vscale x 4 x i1> [[TMP15]], <vscale x 4 x i32> poison)
468 ; CHECK-NEXT: [[PREDPHI:%.*]] = select <vscale x 4 x i1> [[TMP15]], <vscale x 4 x i32> [[WIDE_MASKED_GATHER]], <vscale x 4 x i32> zeroinitializer
469 ; CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds i32, ptr [[DST:%.*]], i64 [[TMP10]]
470 ; CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds i32, ptr [[TMP16]], i32 0
471 ; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> [[PREDPHI]], ptr [[TMP17]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
472 ; CHECK-NEXT: [[INDEX_NEXT2]] = add i64 [[INDEX1]], [[TMP4]]
473 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP9]])
474 ; CHECK-NEXT: [[TMP18:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
475 ; CHECK-NEXT: [[TMP19:%.*]] = extractelement <vscale x 4 x i1> [[TMP18]], i32 0
476 ; CHECK-NEXT: br i1 [[TMP19]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP14:![0-9]+]]
477 ; CHECK: middle.block:
478 ; CHECK-NEXT: br i1 true, label [[FOR_END:%.*]], label [[SCALAR_PH]]
480 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
481 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
483 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[IF_END:%.*]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
484 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[COND]], i64 [[INDEX]]
485 ; CHECK-NEXT: [[TMP20:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
486 ; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i32 [[TMP20]], 0
487 ; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[IF_END]], label [[IF_THEN:%.*]]
489 ; CHECK-NEXT: [[TMP21:%.*]] = load i32, ptr [[SRC]], align 4
490 ; CHECK-NEXT: br label [[IF_END]]
492 ; CHECK-NEXT: [[VAL_0:%.*]] = phi i32 [ [[TMP21]], [[IF_THEN]] ], [ 0, [[FOR_BODY]] ]
493 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[DST]], i64 [[INDEX]]
494 ; CHECK-NEXT: store i32 [[VAL_0]], ptr [[ARRAYIDX1]], align 4
495 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 1
496 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N]]
497 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END]], label [[FOR_BODY]], !llvm.loop [[LOOP15:![0-9]+]]
499 ; CHECK-NEXT: ret void
505 for.body: ; preds = %entry, %if.end
506 %index = phi i64 [ %index.next, %if.end ], [ 0, %entry ]
507 %arrayidx = getelementptr inbounds i32, ptr %cond, i64 %index
508 %0 = load i32, ptr %arrayidx, align 4
509 %tobool.not = icmp eq i32 %0, 0
510 br i1 %tobool.not, label %if.end, label %if.then
512 if.then: ; preds = %for.body
513 %1 = load i32, ptr %src, align 4
516 if.end: ; preds = %if.then, %for.body
517 %val.0 = phi i32 [ %1, %if.then ], [ 0, %for.body ]
518 %arrayidx1 = getelementptr inbounds i32, ptr %dst, i64 %index
519 store i32 %val.0, ptr %arrayidx1, align 4
520 %index.next = add nuw i64 %index, 1
521 %exitcond.not = icmp eq i64 %index.next, %n
522 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0
524 for.end: ; preds = %for.inc, %entry
529 ; The original loop had an unconditional uniform store. Let's make sure
530 ; we don't artificially create new predicated blocks for the load.
531 define void @uniform_store(ptr noalias %dst, ptr noalias readonly %src, i64 %n) #0 {
532 ; CHECK-LABEL: @uniform_store(
534 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
536 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
537 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
538 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
539 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[N:%.*]], [[TMP2]]
540 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
541 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
542 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
543 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
544 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
545 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
546 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[N]], [[TMP6]]
547 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[N]], [[TMP6]]
548 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
549 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[N]])
550 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x ptr> poison, ptr [[DST:%.*]], i64 0
551 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x ptr> [[BROADCAST_SPLATINSERT]], <vscale x 4 x ptr> poison, <vscale x 4 x i32> zeroinitializer
552 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
553 ; CHECK: vector.body:
554 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
555 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
556 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX]], 0
557 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr inbounds i32, ptr [[SRC:%.*]], i64 [[TMP10]]
558 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds i32, ptr [[TMP11]], i32 0
559 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[TMP12]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
560 ; CHECK-NEXT: call void @llvm.masked.scatter.nxv4i32.nxv4p0(<vscale x 4 x i32> [[WIDE_MASKED_LOAD]], <vscale x 4 x ptr> [[BROADCAST_SPLAT]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
561 ; CHECK-NEXT: [[INDEX_NEXT]] = add i64 [[INDEX]], [[TMP4]]
562 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX]], i64 [[TMP9]])
563 ; CHECK-NEXT: [[TMP13:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
564 ; CHECK-NEXT: [[TMP14:%.*]] = extractelement <vscale x 4 x i1> [[TMP13]], i32 0
565 ; CHECK-NEXT: br i1 [[TMP14]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP16:![0-9]+]]
566 ; CHECK: middle.block:
567 ; CHECK-NEXT: br i1 true, label [[FOR_END:%.*]], label [[SCALAR_PH]]
569 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
570 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
572 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
573 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[SRC]], i64 [[INDVARS_IV]]
574 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
575 ; CHECK-NEXT: store i32 [[VAL]], ptr [[DST]], align 4
576 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
577 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], [[N]]
578 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_END]], label [[FOR_BODY]], !llvm.loop [[LOOP17:![0-9]+]]
580 ; CHECK-NEXT: ret void
586 for.body: ; preds = %entry, %for.body
587 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
588 %arrayidx = getelementptr inbounds i32, ptr %src, i64 %indvars.iv
589 %val = load i32, ptr %arrayidx, align 4
590 store i32 %val, ptr %dst, align 4
591 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
592 %exitcond.not = icmp eq i64 %indvars.iv.next, %n
593 br i1 %exitcond.not, label %for.end, label %for.body, !llvm.loop !0
595 for.end: ; preds = %for.body, %entry
600 define void @simple_fdiv(ptr noalias %dst, ptr noalias %src, i64 %n) #0 {
601 ; CHECK-LABEL: @simple_fdiv(
603 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
604 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
606 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
607 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
608 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
609 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[UMAX]], [[TMP2]]
610 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
611 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
612 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
613 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
614 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
615 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
616 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[UMAX]], [[TMP6]]
617 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[UMAX]], [[TMP6]]
618 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
619 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[UMAX]])
620 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
621 ; CHECK: vector.body:
622 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT3:%.*]], [[VECTOR_BODY]] ]
623 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
624 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX1]], 0
625 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr float, ptr [[SRC:%.*]], i64 [[TMP10]]
626 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr float, ptr [[DST:%.*]], i64 [[TMP10]]
627 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr float, ptr [[TMP11]], i32 0
628 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <vscale x 4 x float> @llvm.masked.load.nxv4f32.p0(ptr [[TMP13]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x float> poison)
629 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr float, ptr [[TMP12]], i32 0
630 ; CHECK-NEXT: [[WIDE_MASKED_LOAD2:%.*]] = call <vscale x 4 x float> @llvm.masked.load.nxv4f32.p0(ptr [[TMP14]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x float> poison)
631 ; CHECK-NEXT: [[TMP15:%.*]] = fdiv <vscale x 4 x float> [[WIDE_MASKED_LOAD]], [[WIDE_MASKED_LOAD2]]
632 ; CHECK-NEXT: call void @llvm.masked.store.nxv4f32.p0(<vscale x 4 x float> [[TMP15]], ptr [[TMP14]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
633 ; CHECK-NEXT: [[INDEX_NEXT3]] = add i64 [[INDEX1]], [[TMP4]]
634 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP9]])
635 ; CHECK-NEXT: [[TMP16:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
636 ; CHECK-NEXT: [[TMP17:%.*]] = extractelement <vscale x 4 x i1> [[TMP16]], i32 0
637 ; CHECK-NEXT: br i1 [[TMP17]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP18:![0-9]+]]
638 ; CHECK: middle.block:
639 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
641 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
642 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
644 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
645 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr float, ptr [[SRC]], i64 [[INDEX]]
646 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr float, ptr [[DST]], i64 [[INDEX]]
647 ; CHECK-NEXT: [[VAL1:%.*]] = load float, ptr [[GEP1]], align 4
648 ; CHECK-NEXT: [[VAL2:%.*]] = load float, ptr [[GEP2]], align 4
649 ; CHECK-NEXT: [[RES:%.*]] = fdiv float [[VAL1]], [[VAL2]]
650 ; CHECK-NEXT: store float [[RES]], ptr [[GEP2]], align 4
651 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
652 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
653 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP19:![0-9]+]]
654 ; CHECK: while.end.loopexit:
655 ; CHECK-NEXT: ret void
660 while.body: ; preds = %while.body, %entry
661 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
662 %gep1 = getelementptr float, ptr %src, i64 %index
663 %gep2 = getelementptr float, ptr %dst, i64 %index
664 %val1 = load float, ptr %gep1
665 %val2 = load float, ptr %gep2
666 %res = fdiv float %val1, %val2
667 store float %res, ptr %gep2
668 %index.next = add nsw i64 %index, 1
669 %cmp10 = icmp ult i64 %index.next, %n
670 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
672 while.end.loopexit: ; preds = %while.body
676 ; Integer divides can throw exceptions; if we vectorize, we must ensure
677 ; that speculated lanes don't fault.
678 define void @simple_idiv(ptr noalias %dst, ptr noalias %src, i64 %n) #0 {
679 ; CHECK-LABEL: @simple_idiv(
681 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
682 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
684 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
685 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
686 ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], 1
687 ; CHECK-NEXT: [[N_RND_UP:%.*]] = add i64 [[UMAX]], [[TMP2]]
688 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[N_RND_UP]], [[TMP1]]
689 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[N_RND_UP]], [[N_MOD_VF]]
690 ; CHECK-NEXT: [[TMP3:%.*]] = call i64 @llvm.vscale.i64()
691 ; CHECK-NEXT: [[TMP4:%.*]] = mul i64 [[TMP3]], 4
692 ; CHECK-NEXT: [[TMP5:%.*]] = call i64 @llvm.vscale.i64()
693 ; CHECK-NEXT: [[TMP6:%.*]] = mul i64 [[TMP5]], 4
694 ; CHECK-NEXT: [[TMP7:%.*]] = sub i64 [[UMAX]], [[TMP6]]
695 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ugt i64 [[UMAX]], [[TMP6]]
696 ; CHECK-NEXT: [[TMP9:%.*]] = select i1 [[TMP8]], i64 [[TMP7]], i64 0
697 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_ENTRY:%.*]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 0, i64 [[UMAX]])
698 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
699 ; CHECK: vector.body:
700 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT3:%.*]], [[VECTOR_BODY]] ]
701 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = phi <vscale x 4 x i1> [ [[ACTIVE_LANE_MASK_ENTRY]], [[VECTOR_PH]] ], [ [[ACTIVE_LANE_MASK_NEXT:%.*]], [[VECTOR_BODY]] ]
702 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[INDEX1]], 0
703 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr i32, ptr [[SRC:%.*]], i64 [[TMP10]]
704 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, ptr [[DST:%.*]], i64 [[TMP10]]
705 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr i32, ptr [[TMP11]], i32 0
706 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[TMP13]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
707 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr i32, ptr [[TMP12]], i32 0
708 ; CHECK-NEXT: [[WIDE_MASKED_LOAD2:%.*]] = call <vscale x 4 x i32> @llvm.masked.load.nxv4i32.p0(ptr [[TMP14]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> poison)
709 ; CHECK-NEXT: [[TMP15:%.*]] = select <vscale x 4 x i1> [[ACTIVE_LANE_MASK]], <vscale x 4 x i32> [[WIDE_MASKED_LOAD2]], <vscale x 4 x i32> splat (i32 1)
710 ; CHECK-NEXT: [[TMP16:%.*]] = udiv <vscale x 4 x i32> [[WIDE_MASKED_LOAD]], [[TMP15]]
711 ; CHECK-NEXT: call void @llvm.masked.store.nxv4i32.p0(<vscale x 4 x i32> [[TMP16]], ptr [[TMP14]], i32 4, <vscale x 4 x i1> [[ACTIVE_LANE_MASK]])
712 ; CHECK-NEXT: [[INDEX_NEXT3]] = add i64 [[INDEX1]], [[TMP4]]
713 ; CHECK-NEXT: [[ACTIVE_LANE_MASK_NEXT]] = call <vscale x 4 x i1> @llvm.get.active.lane.mask.nxv4i1.i64(i64 [[INDEX1]], i64 [[TMP9]])
714 ; CHECK-NEXT: [[TMP17:%.*]] = xor <vscale x 4 x i1> [[ACTIVE_LANE_MASK_NEXT]], splat (i1 true)
715 ; CHECK-NEXT: [[TMP18:%.*]] = extractelement <vscale x 4 x i1> [[TMP17]], i32 0
716 ; CHECK-NEXT: br i1 [[TMP18]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP20:![0-9]+]]
717 ; CHECK: middle.block:
718 ; CHECK-NEXT: br i1 true, label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
720 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
721 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
723 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
724 ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[SRC]], i64 [[INDEX]]
725 ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[DST]], i64 [[INDEX]]
726 ; CHECK-NEXT: [[VAL1:%.*]] = load i32, ptr [[GEP1]], align 4
727 ; CHECK-NEXT: [[VAL2:%.*]] = load i32, ptr [[GEP2]], align 4
728 ; CHECK-NEXT: [[RES:%.*]] = udiv i32 [[VAL1]], [[VAL2]]
729 ; CHECK-NEXT: store i32 [[RES]], ptr [[GEP2]], align 4
730 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
731 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], [[N]]
732 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP21:![0-9]+]]
733 ; CHECK: while.end.loopexit:
734 ; CHECK-NEXT: ret void
739 while.body: ; preds = %while.body, %entry
740 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
741 %gep1 = getelementptr i32, ptr %src, i64 %index
742 %gep2 = getelementptr i32, ptr %dst, i64 %index
743 %val1 = load i32, ptr %gep1
744 %val2 = load i32, ptr %gep2
745 %res = udiv i32 %val1, %val2
746 store i32 %res, ptr %gep2
747 %index.next = add nsw i64 %index, 1
748 %cmp10 = icmp ult i64 %index.next, %n
749 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
751 while.end.loopexit: ; preds = %while.body
755 define void @simple_memset_trip1024(i32 %val, ptr %ptr, i64 %n) #0 {
756 ; CHECK-LABEL: @simple_memset_trip1024(
758 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
759 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
760 ; CHECK-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
762 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
763 ; CHECK-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 4
764 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 1024, [[TMP3]]
765 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 1024, [[N_MOD_VF]]
766 ; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
767 ; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 4
768 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 4 x i32> poison, i32 [[VAL:%.*]], i64 0
769 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[BROADCAST_SPLATINSERT]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer
770 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
771 ; CHECK: vector.body:
772 ; CHECK-NEXT: [[INDEX1:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT2:%.*]], [[VECTOR_BODY]] ]
773 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[INDEX1]], 0
774 ; CHECK-NEXT: [[TMP7:%.*]] = getelementptr i32, ptr [[PTR:%.*]], i64 [[TMP6]]
775 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr i32, ptr [[TMP7]], i32 0
776 ; CHECK-NEXT: store <vscale x 4 x i32> [[BROADCAST_SPLAT]], ptr [[TMP8]], align 4
777 ; CHECK-NEXT: [[INDEX_NEXT2]] = add nuw i64 [[INDEX1]], [[TMP5]]
778 ; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i64 [[INDEX_NEXT2]], [[N_VEC]]
779 ; CHECK-NEXT: br i1 [[TMP9]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP22:![0-9]+]]
780 ; CHECK: middle.block:
781 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 1024, [[N_VEC]]
782 ; CHECK-NEXT: br i1 [[CMP_N]], label [[WHILE_END_LOOPEXIT:%.*]], label [[SCALAR_PH]]
784 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
785 ; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
787 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ [[INDEX_NEXT:%.*]], [[WHILE_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
788 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[PTR]], i64 [[INDEX]]
789 ; CHECK-NEXT: store i32 [[VAL]], ptr [[GEP]], align 4
790 ; CHECK-NEXT: [[INDEX_NEXT]] = add nsw i64 [[INDEX]], 1
791 ; CHECK-NEXT: [[CMP10:%.*]] = icmp ult i64 [[INDEX_NEXT]], 1024
792 ; CHECK-NEXT: br i1 [[CMP10]], label [[WHILE_BODY]], label [[WHILE_END_LOOPEXIT]], !llvm.loop [[LOOP23:![0-9]+]]
793 ; CHECK: while.end.loopexit:
794 ; CHECK-NEXT: ret void
799 while.body: ; preds = %while.body, %entry
800 %index = phi i64 [ %index.next, %while.body ], [ 0, %entry ]
801 %gep = getelementptr i32, ptr %ptr, i64 %index
802 store i32 %val, ptr %gep
803 %index.next = add nsw i64 %index, 1
804 %cmp10 = icmp ult i64 %index.next, 1024
805 br i1 %cmp10, label %while.body, label %while.end.loopexit, !llvm.loop !0
807 while.end.loopexit: ; preds = %while.body
811 !0 = distinct !{!0, !1, !2}
812 !1 = !{!"llvm.loop.vectorize.width", i32 4}
813 !2 = !{!"llvm.loop.vectorize.scalable.enable", i1 true}
814 !3 = distinct !{!3, !4}
815 !4 = !{!"llvm.loop.vectorize.width", i32 4}
817 attributes #0 = { "target-features"="+sve" vscale_range(1,16) }