Debian Codegraph @

llvm/test/CodeGen/Thumb2/LowOverheadLoops/tail-pred-basic.ll

raw
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
2 ; RUN: opt -mtriple=thumbv8.1m.main -mve-tail-predication -tail-predication=enabled -mattr=+mve,+lob %s -S -o - | FileCheck %s
3
4 define dso_local arm_aapcs_vfpcc void @mul_v16i8(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {
5 ; CHECK-LABEL: define dso_local arm_aapcs_vfpcc void @mul_v16i8(
6 ; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias captures(none) [[C:%.*]], i32 [[N:%.*]]) #[[ATTR0:[0-9]+]] {
7 ; CHECK-NEXT: [[ENTRY:.*:]]
8 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[N]], 0
9 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[N]], 15
10 ; CHECK-NEXT: [[TMP9:%.*]] = lshr i32 [[TMP8]], 4
11 ; CHECK-NEXT: [[TMP10:%.*]] = shl nuw i32 [[TMP9]], 4
12 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -16
13 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP11]], 4
14 ; CHECK-NEXT: [[TMP13:%.*]] = add nuw nsw i32 [[TMP12]], 1
15 ; CHECK-NEXT: br i1 [[CMP8]], label %[[FOR_COND_CLEANUP:.*]], label %[[VECTOR_PH:.*]]
16 ; CHECK: [[VECTOR_PH]]:
17 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP13]])
18 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
19 ; CHECK: [[VECTOR_BODY]]:
20 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
21 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
22 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[N]], %[[VECTOR_PH]] ], [ [[TMP2:%.*]], %[[VECTOR_BODY]] ]
23 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i8, ptr [[A]], i32 [[INDEX]]
24 ; CHECK-NEXT: [[TMP1:%.*]] = call <16 x i1> @llvm.arm.mve.vctp8(i32 [[TMP0]])
25 ; CHECK-NEXT: [[TMP2]] = sub i32 [[TMP0]], 16
26 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = tail call <16 x i8> @llvm.masked.load.v16i8.p0(ptr align 4 [[TMP]], <16 x i1> [[TMP1]], <16 x i8> undef)
27 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i8, ptr [[B]], i32 [[INDEX]]
28 ; CHECK-NEXT: [[WIDE_MASKED_LOAD2:%.*]] = tail call <16 x i8> @llvm.masked.load.v16i8.p0(ptr align 4 [[TMP3]], <16 x i1> [[TMP1]], <16 x i8> undef)
29 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw <16 x i8> [[WIDE_MASKED_LOAD2]], [[WIDE_MASKED_LOAD]]
30 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i8, ptr [[C]], i32 [[INDEX]]
31 ; CHECK-NEXT: tail call void @llvm.masked.store.v16i8.p0(<16 x i8> [[MUL]], ptr align 4 [[TMP6]], <16 x i1> [[TMP1]])
32 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 16
33 ; CHECK-NEXT: [[TMP15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP14]], i32 1)
34 ; CHECK-NEXT: [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
35 ; CHECK-NEXT: br i1 [[TMP16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
36 ; CHECK: [[FOR_COND_CLEANUP]]:
37 ; CHECK-NEXT: ret void
38 ;
39 entry:
40 %cmp8 = icmp eq i32 %N, 0
41 %tmp8 = add i32 %N, 15
42 %tmp9 = lshr i32 %tmp8, 4
43 %tmp10 = shl nuw i32 %tmp9, 4
44 %tmp11 = add i32 %tmp10, -16
45 %tmp12 = lshr i32 %tmp11, 4
46 %tmp13 = add nuw nsw i32 %tmp12, 1
47 br i1 %cmp8, label %for.cond.cleanup, label %vector.ph
48
49 vector.ph: ; preds = %entry
50 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)
51 br label %vector.body
52
53 vector.body: ; preds = %vector.body, %vector.ph
54 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
55 %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]
56 %tmp = getelementptr inbounds i8, ptr %a, i32 %index
57 %active.lane.mask = call <16 x i1> @llvm.get.active.lane.mask.v16i1.i32(i32 %index, i32 %N)
58 %wide.masked.load = tail call <16 x i8> @llvm.masked.load.v16i8.p0(ptr %tmp, i32 4, <16 x i1> %active.lane.mask, <16 x i8> undef)
59 %tmp3 = getelementptr inbounds i8, ptr %b, i32 %index
60 %wide.masked.load2 = tail call <16 x i8> @llvm.masked.load.v16i8.p0(ptr %tmp3, i32 4, <16 x i1> %active.lane.mask, <16 x i8> undef)
61 %mul = mul nsw <16 x i8> %wide.masked.load2, %wide.masked.load
62 %tmp6 = getelementptr inbounds i8, ptr %c, i32 %index
63 tail call void @llvm.masked.store.v16i8.p0(<16 x i8> %mul, ptr %tmp6, i32 4, <16 x i1> %active.lane.mask)
64 %index.next = add i32 %index, 16
65 %tmp15 = call i32 @llvm.loop.decrement.reg.i32(i32 %tmp14, i32 1)
66 %tmp16 = icmp ne i32 %tmp15, 0
67 br i1 %tmp16, label %vector.body, label %for.cond.cleanup
68
69 for.cond.cleanup: ; preds = %vector.body, %entry
70 ret void
71 }
72
73 define dso_local arm_aapcs_vfpcc void @mul_v8i16(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {
74 ; CHECK-LABEL: define dso_local arm_aapcs_vfpcc void @mul_v8i16(
75 ; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias captures(none) [[C:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
76 ; CHECK-NEXT: [[ENTRY:.*:]]
77 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[N]], 0
78 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[N]], 7
79 ; CHECK-NEXT: [[TMP9:%.*]] = lshr i32 [[TMP8]], 3
80 ; CHECK-NEXT: [[TMP10:%.*]] = shl nuw i32 [[TMP9]], 3
81 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -8
82 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP11]], 3
83 ; CHECK-NEXT: [[TMP13:%.*]] = add nuw nsw i32 [[TMP12]], 1
84 ; CHECK-NEXT: br i1 [[CMP8]], label %[[FOR_COND_CLEANUP:.*]], label %[[VECTOR_PH:.*]]
85 ; CHECK: [[VECTOR_PH]]:
86 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP13]])
87 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
88 ; CHECK: [[VECTOR_BODY]]:
89 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
90 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
91 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[N]], %[[VECTOR_PH]] ], [ [[TMP2:%.*]], %[[VECTOR_BODY]] ]
92 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i16, ptr [[A]], i32 [[INDEX]]
93 ; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.vctp16(i32 [[TMP0]])
94 ; CHECK-NEXT: [[TMP2]] = sub i32 [[TMP0]], 8
95 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = tail call <8 x i16> @llvm.masked.load.v8i16.p0(ptr align 4 [[TMP]], <8 x i1> [[TMP1]], <8 x i16> undef)
96 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i16, ptr [[B]], i32 [[INDEX]]
97 ; CHECK-NEXT: [[WIDE_MASKED_LOAD2:%.*]] = tail call <8 x i16> @llvm.masked.load.v8i16.p0(ptr align 4 [[TMP3]], <8 x i1> [[TMP1]], <8 x i16> undef)
98 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw <8 x i16> [[WIDE_MASKED_LOAD2]], [[WIDE_MASKED_LOAD]]
99 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i16, ptr [[C]], i32 [[INDEX]]
100 ; CHECK-NEXT: tail call void @llvm.masked.store.v8i16.p0(<8 x i16> [[MUL]], ptr align 4 [[TMP6]], <8 x i1> [[TMP1]])
101 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 8
102 ; CHECK-NEXT: [[TMP15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP14]], i32 1)
103 ; CHECK-NEXT: [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
104 ; CHECK-NEXT: br i1 [[TMP16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
105 ; CHECK: [[FOR_COND_CLEANUP]]:
106 ; CHECK-NEXT: ret void
107 ;
108 entry:
109 %cmp8 = icmp eq i32 %N, 0
110 %tmp8 = add i32 %N, 7
111 %tmp9 = lshr i32 %tmp8, 3
112 %tmp10 = shl nuw i32 %tmp9, 3
113 %tmp11 = add i32 %tmp10, -8
114 %tmp12 = lshr i32 %tmp11, 3
115 %tmp13 = add nuw nsw i32 %tmp12, 1
116 br i1 %cmp8, label %for.cond.cleanup, label %vector.ph
117
118 vector.ph: ; preds = %entry
119 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)
120 br label %vector.body
121
122 vector.body: ; preds = %vector.body, %vector.ph
123 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
124 %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]
125 %tmp = getelementptr inbounds i16, ptr %a, i32 %index
126 %active.lane.mask = call <8 x i1> @llvm.get.active.lane.mask.v8i1.i32(i32 %index, i32 %N)
127 %wide.masked.load = tail call <8 x i16> @llvm.masked.load.v8i16.p0(ptr %tmp, i32 4, <8 x i1> %active.lane.mask, <8 x i16> undef)
128 %tmp3 = getelementptr inbounds i16, ptr %b, i32 %index
129 %wide.masked.load2 = tail call <8 x i16> @llvm.masked.load.v8i16.p0(ptr %tmp3, i32 4, <8 x i1> %active.lane.mask, <8 x i16> undef)
130 %mul = mul nsw <8 x i16> %wide.masked.load2, %wide.masked.load
131 %tmp6 = getelementptr inbounds i16, ptr %c, i32 %index
132 tail call void @llvm.masked.store.v8i16.p0(<8 x i16> %mul, ptr %tmp6, i32 4, <8 x i1> %active.lane.mask)
133 %index.next = add i32 %index, 8
134 %tmp15 = call i32 @llvm.loop.decrement.reg.i32(i32 %tmp14, i32 1)
135 %tmp16 = icmp ne i32 %tmp15, 0
136 br i1 %tmp16, label %vector.body, label %for.cond.cleanup
137
138 for.cond.cleanup: ; preds = %vector.body, %entry
139 ret void
140 }
141
142 define dso_local arm_aapcs_vfpcc void @mul_v4i32(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {
143 ; CHECK-LABEL: define dso_local arm_aapcs_vfpcc void @mul_v4i32(
144 ; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias captures(none) [[C:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
145 ; CHECK-NEXT: [[ENTRY:.*:]]
146 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[N]], 0
147 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[N]], 3
148 ; CHECK-NEXT: [[TMP9:%.*]] = lshr i32 [[TMP8]], 2
149 ; CHECK-NEXT: [[TMP10:%.*]] = shl nuw i32 [[TMP9]], 2
150 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -4
151 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP11]], 2
152 ; CHECK-NEXT: [[TMP13:%.*]] = add nuw nsw i32 [[TMP12]], 1
153 ; CHECK-NEXT: br i1 [[CMP8]], label %[[FOR_COND_CLEANUP:.*]], label %[[VECTOR_PH:.*]]
154 ; CHECK: [[VECTOR_PH]]:
155 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP13]])
156 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
157 ; CHECK: [[VECTOR_BODY]]:
158 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
159 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
160 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[N]], %[[VECTOR_PH]] ], [ [[TMP2:%.*]], %[[VECTOR_BODY]] ]
161 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 [[INDEX]]
162 ; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.vctp32(i32 [[TMP0]])
163 ; CHECK-NEXT: [[TMP2]] = sub i32 [[TMP0]], 4
164 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP]], <4 x i1> [[TMP1]], <4 x i32> undef)
165 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[INDEX]]
166 ; CHECK-NEXT: [[WIDE_MASKED_LOAD2:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP3]], <4 x i1> [[TMP1]], <4 x i32> undef)
167 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw <4 x i32> [[WIDE_MASKED_LOAD2]], [[WIDE_MASKED_LOAD]]
168 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[C]], i32 [[INDEX]]
169 ; CHECK-NEXT: tail call void @llvm.masked.store.v4i32.p0(<4 x i32> [[MUL]], ptr align 4 [[TMP6]], <4 x i1> [[TMP1]])
170 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
171 ; CHECK-NEXT: [[TMP15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP14]], i32 1)
172 ; CHECK-NEXT: [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
173 ; CHECK-NEXT: br i1 [[TMP16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
174 ; CHECK: [[FOR_COND_CLEANUP]]:
175 ; CHECK-NEXT: ret void
176 ;
177 entry:
178 %cmp8 = icmp eq i32 %N, 0
179 %tmp8 = add i32 %N, 3
180 %tmp9 = lshr i32 %tmp8, 2
181 %tmp10 = shl nuw i32 %tmp9, 2
182 %tmp11 = add i32 %tmp10, -4
183 %tmp12 = lshr i32 %tmp11, 2
184 %tmp13 = add nuw nsw i32 %tmp12, 1
185 br i1 %cmp8, label %for.cond.cleanup, label %vector.ph
186
187 vector.ph: ; preds = %entry
188 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)
189 br label %vector.body
190
191 vector.body: ; preds = %vector.body, %vector.ph
192 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
193 %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]
194 %tmp = getelementptr inbounds i32, ptr %a, i32 %index
195 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %N)
196 %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
197 %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index
198 %wide.masked.load2 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
199 %mul = mul nsw <4 x i32> %wide.masked.load2, %wide.masked.load
200 %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index
201 tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %mul, ptr %tmp6, i32 4, <4 x i1> %active.lane.mask)
202 %index.next = add i32 %index, 4
203 %tmp15 = call i32 @llvm.loop.decrement.reg.i32(i32 %tmp14, i32 1)
204 %tmp16 = icmp ne i32 %tmp15, 0
205 br i1 %tmp16, label %vector.body, label %for.cond.cleanup
206
207 for.cond.cleanup: ; preds = %vector.body, %entry
208 ret void
209 }
210
211 define dso_local arm_aapcs_vfpcc void @split_vector(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {
212 ; CHECK-LABEL: define dso_local arm_aapcs_vfpcc void @split_vector(
213 ; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias captures(none) [[C:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
214 ; CHECK-NEXT: [[ENTRY:.*:]]
215 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[N]], 0
216 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[N]], 3
217 ; CHECK-NEXT: [[TMP9:%.*]] = lshr i32 [[TMP8]], 2
218 ; CHECK-NEXT: [[TMP10:%.*]] = shl nuw i32 [[TMP9]], 2
219 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -4
220 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP11]], 2
221 ; CHECK-NEXT: [[TMP13:%.*]] = add nuw nsw i32 [[TMP12]], 1
222 ; CHECK-NEXT: br i1 [[CMP8]], label %[[FOR_COND_CLEANUP:.*]], label %[[VECTOR_PH:.*]]
223 ; CHECK: [[VECTOR_PH]]:
224 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP13]])
225 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
226 ; CHECK: [[VECTOR_BODY]]:
227 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
228 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
229 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[N]], %[[VECTOR_PH]] ], [ [[TMP2:%.*]], %[[VECTOR_BODY]] ]
230 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 [[INDEX]]
231 ; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.vctp32(i32 [[TMP0]])
232 ; CHECK-NEXT: [[TMP2]] = sub i32 [[TMP0]], 4
233 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP]], <4 x i1> [[TMP1]], <4 x i32> undef)
234 ; CHECK-NEXT: [[EXTRACT_1_LOW:%.*]] = shufflevector <4 x i32> [[WIDE_MASKED_LOAD]], <4 x i32> undef, <2 x i32> <i32 0, i32 2>
235 ; CHECK-NEXT: [[EXTRACT_1_HIGH:%.*]] = shufflevector <4 x i32> [[WIDE_MASKED_LOAD]], <4 x i32> undef, <2 x i32> <i32 1, i32 3>
236 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[INDEX]]
237 ; CHECK-NEXT: [[WIDE_MASKED_LOAD2:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP3]], <4 x i1> [[TMP1]], <4 x i32> undef)
238 ; CHECK-NEXT: [[EXTRACT_2_LOW:%.*]] = shufflevector <4 x i32> [[WIDE_MASKED_LOAD2]], <4 x i32> undef, <2 x i32> <i32 0, i32 2>
239 ; CHECK-NEXT: [[EXTRACT_2_HIGH:%.*]] = shufflevector <4 x i32> [[WIDE_MASKED_LOAD2]], <4 x i32> undef, <2 x i32> <i32 1, i32 3>
240 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw <2 x i32> [[EXTRACT_1_LOW]], [[EXTRACT_2_LOW]]
241 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> [[EXTRACT_1_HIGH]], [[EXTRACT_2_HIGH]]
242 ; CHECK-NEXT: [[COMBINE:%.*]] = shufflevector <2 x i32> [[MUL]], <2 x i32> [[SUB]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
243 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[C]], i32 [[INDEX]]
244 ; CHECK-NEXT: tail call void @llvm.masked.store.v4i32.p0(<4 x i32> [[COMBINE]], ptr align 4 [[TMP6]], <4 x i1> [[TMP1]])
245 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
246 ; CHECK-NEXT: [[TMP15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP14]], i32 1)
247 ; CHECK-NEXT: [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
248 ; CHECK-NEXT: br i1 [[TMP16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
249 ; CHECK: [[FOR_COND_CLEANUP]]:
250 ; CHECK-NEXT: ret void
251 ;
252 entry:
253 %cmp8 = icmp eq i32 %N, 0
254 %tmp8 = add i32 %N, 3
255 %tmp9 = lshr i32 %tmp8, 2
256 %tmp10 = shl nuw i32 %tmp9, 2
257 %tmp11 = add i32 %tmp10, -4
258 %tmp12 = lshr i32 %tmp11, 2
259 %tmp13 = add nuw nsw i32 %tmp12, 1
260 br i1 %cmp8, label %for.cond.cleanup, label %vector.ph
261
262 vector.ph: ; preds = %entry
263 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)
264 br label %vector.body
265
266 vector.body: ; preds = %vector.body, %vector.ph
267 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
268 %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]
269 %tmp = getelementptr inbounds i32, ptr %a, i32 %index
270 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %N)
271 %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
272 %extract.1.low = shufflevector <4 x i32> %wide.masked.load, <4 x i32> undef, < 2 x i32> < i32 0, i32 2>
273 %extract.1.high = shufflevector <4 x i32> %wide.masked.load, <4 x i32> undef, < 2 x i32> < i32 1, i32 3>
274 %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index
275 %wide.masked.load2 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
276 %extract.2.low = shufflevector <4 x i32> %wide.masked.load2, <4 x i32> undef, < 2 x i32> < i32 0, i32 2>
277 %extract.2.high = shufflevector <4 x i32> %wide.masked.load2, <4 x i32> undef, < 2 x i32> < i32 1, i32 3>
278 %mul = mul nsw <2 x i32> %extract.1.low, %extract.2.low
279 %sub = sub nsw <2 x i32> %extract.1.high, %extract.2.high
280 %combine = shufflevector <2 x i32> %mul, <2 x i32> %sub, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
281 %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index
282 tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %combine, ptr %tmp6, i32 4, <4 x i1> %active.lane.mask)
283 %index.next = add i32 %index, 4
284 %tmp15 = call i32 @llvm.loop.decrement.reg.i32(i32 %tmp14, i32 1)
285 %tmp16 = icmp ne i32 %tmp15, 0
286 br i1 %tmp16, label %vector.body, label %for.cond.cleanup
287
288 for.cond.cleanup: ; preds = %vector.body, %entry
289 ret void
290 }
291
292 ; One of the loads now uses ult predicate.
293 define dso_local arm_aapcs_vfpcc void @mismatch_load_pred(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {
294 ; CHECK-LABEL: define dso_local arm_aapcs_vfpcc void @mismatch_load_pred(
295 ; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias captures(none) [[C:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
296 ; CHECK-NEXT: [[ENTRY:.*:]]
297 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[N]], 0
298 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[N]], 3
299 ; CHECK-NEXT: [[TMP9:%.*]] = lshr i32 [[TMP8]], 2
300 ; CHECK-NEXT: [[TMP10:%.*]] = shl nuw i32 [[TMP9]], 2
301 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -4
302 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP11]], 2
303 ; CHECK-NEXT: [[TMP13:%.*]] = add nuw nsw i32 [[TMP12]], 1
304 ; CHECK-NEXT: br i1 [[CMP8]], label %[[FOR_COND_CLEANUP:.*]], label %[[VECTOR_PH:.*]]
305 ; CHECK: [[VECTOR_PH]]:
306 ; CHECK-NEXT: [[TRIP_COUNT_MINUS_1:%.*]] = add i32 [[N]], -1
307 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT10:%.*]] = insertelement <4 x i32> undef, i32 [[TRIP_COUNT_MINUS_1]], i32 0
308 ; CHECK-NEXT: [[BROADCAST_SPLAT11:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT10]], <4 x i32> undef, <4 x i32> zeroinitializer
309 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP13]])
310 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
311 ; CHECK: [[VECTOR_BODY]]:
312 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
313 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
314 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[N]], %[[VECTOR_PH]] ], [ [[TMP2:%.*]], %[[VECTOR_BODY]] ]
315 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 [[INDEX]], i32 0
316 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer
317 ; CHECK-NEXT: [[INDUCTION:%.*]] = add <4 x i32> [[BROADCAST_SPLAT]], <i32 0, i32 1, i32 2, i32 3>
318 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 [[INDEX]]
319 ; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.vctp32(i32 [[TMP0]])
320 ; CHECK-NEXT: [[TMP2]] = sub i32 [[TMP0]], 4
321 ; CHECK-NEXT: [[WRONG:%.*]] = icmp ult <4 x i32> [[INDUCTION]], [[BROADCAST_SPLAT11]]
322 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP]], <4 x i1> [[TMP1]], <4 x i32> undef)
323 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[INDEX]]
324 ; CHECK-NEXT: [[WIDE_MASKED_LOAD12:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP3]], <4 x i1> [[WRONG]], <4 x i32> undef)
325 ; CHECK-NEXT: [[TMP5:%.*]] = mul nsw <4 x i32> [[WIDE_MASKED_LOAD12]], [[WIDE_MASKED_LOAD]]
326 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[C]], i32 [[INDEX]]
327 ; CHECK-NEXT: tail call void @llvm.masked.store.v4i32.p0(<4 x i32> [[TMP5]], ptr align 4 [[TMP6]], <4 x i1> [[TMP1]])
328 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
329 ; CHECK-NEXT: [[TMP15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP14]], i32 1)
330 ; CHECK-NEXT: [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
331 ; CHECK-NEXT: br i1 [[TMP16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
332 ; CHECK: [[FOR_COND_CLEANUP]]:
333 ; CHECK-NEXT: ret void
334 ;
335 entry:
336 %cmp8 = icmp eq i32 %N, 0
337 %tmp8 = add i32 %N, 3
338 %tmp9 = lshr i32 %tmp8, 2
339 %tmp10 = shl nuw i32 %tmp9, 2
340 %tmp11 = add i32 %tmp10, -4
341 %tmp12 = lshr i32 %tmp11, 2
342 %tmp13 = add nuw nsw i32 %tmp12, 1
343 br i1 %cmp8, label %for.cond.cleanup, label %vector.ph
344
345 vector.ph: ; preds = %entry
346 %trip.count.minus.1 = add i32 %N, -1
347 %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0
348 %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer
349 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)
350 br label %vector.body
351
352 vector.body: ; preds = %vector.body, %vector.ph
353 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
354 %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]
355 %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0
356 %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
357 %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>
358 %tmp = getelementptr inbounds i32, ptr %a, i32 %index
359 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %N)
360 %wrong = icmp ult <4 x i32> %induction, %broadcast.splat11
361 %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
362 %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index
363 %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %wrong, <4 x i32> undef)
364 %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load
365 %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index
366 tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %active.lane.mask)
367 %index.next = add i32 %index, 4
368 %tmp15 = call i32 @llvm.loop.decrement.reg.i32(i32 %tmp14, i32 1)
369 %tmp16 = icmp ne i32 %tmp15, 0
370 br i1 %tmp16, label %vector.body, label %for.cond.cleanup
371
372 for.cond.cleanup: ; preds = %vector.body, %entry
373 ret void
374 }
375
376 ; The store now uses ult predicate.
377 define dso_local arm_aapcs_vfpcc void @mismatch_store_pred(ptr noalias nocapture readonly %a, ptr noalias nocapture readonly %b, ptr noalias nocapture %c, i32 %N) {
378 ; CHECK-LABEL: define dso_local arm_aapcs_vfpcc void @mismatch_store_pred(
379 ; CHECK-SAME: ptr noalias readonly captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias captures(none) [[C:%.*]], i32 [[N:%.*]]) #[[ATTR0]] {
380 ; CHECK-NEXT: [[ENTRY:.*:]]
381 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[N]], 0
382 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[N]], 3
383 ; CHECK-NEXT: [[TMP9:%.*]] = lshr i32 [[TMP8]], 2
384 ; CHECK-NEXT: [[TMP10:%.*]] = shl nuw i32 [[TMP9]], 2
385 ; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], -4
386 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i32 [[TMP11]], 2
387 ; CHECK-NEXT: [[TMP13:%.*]] = add nuw nsw i32 [[TMP12]], 1
388 ; CHECK-NEXT: br i1 [[CMP8]], label %[[FOR_COND_CLEANUP:.*]], label %[[VECTOR_PH:.*]]
389 ; CHECK: [[VECTOR_PH]]:
390 ; CHECK-NEXT: [[TRIP_COUNT_MINUS_1:%.*]] = add i32 [[N]], -1
391 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT10:%.*]] = insertelement <4 x i32> undef, i32 [[TRIP_COUNT_MINUS_1]], i32 0
392 ; CHECK-NEXT: [[BROADCAST_SPLAT11:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT10]], <4 x i32> undef, <4 x i32> zeroinitializer
393 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP13]])
394 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
395 ; CHECK: [[VECTOR_BODY]]:
396 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
397 ; CHECK-NEXT: [[TMP14:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
398 ; CHECK-NEXT: [[TMP0:%.*]] = phi i32 [ [[N]], %[[VECTOR_PH]] ], [ [[TMP2:%.*]], %[[VECTOR_BODY]] ]
399 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i32> undef, i32 [[INDEX]], i32 0
400 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i32> [[BROADCAST_SPLATINSERT]], <4 x i32> undef, <4 x i32> zeroinitializer
401 ; CHECK-NEXT: [[INDUCTION:%.*]] = add <4 x i32> [[BROADCAST_SPLAT]], <i32 0, i32 1, i32 2, i32 3>
402 ; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 [[INDEX]]
403 ; CHECK-NEXT: [[TMP1:%.*]] = call <4 x i1> @llvm.arm.mve.vctp32(i32 [[TMP0]])
404 ; CHECK-NEXT: [[TMP2]] = sub i32 [[TMP0]], 4
405 ; CHECK-NEXT: [[WRONG:%.*]] = icmp ult <4 x i32> [[INDUCTION]], [[BROADCAST_SPLAT11]]
406 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP]], <4 x i1> [[TMP1]], <4 x i32> undef)
407 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[INDEX]]
408 ; CHECK-NEXT: [[WIDE_MASKED_LOAD12:%.*]] = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[TMP3]], <4 x i1> [[TMP1]], <4 x i32> undef)
409 ; CHECK-NEXT: [[TMP5:%.*]] = mul nsw <4 x i32> [[WIDE_MASKED_LOAD12]], [[WIDE_MASKED_LOAD]]
410 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[C]], i32 [[INDEX]]
411 ; CHECK-NEXT: tail call void @llvm.masked.store.v4i32.p0(<4 x i32> [[TMP5]], ptr align 4 [[TMP6]], <4 x i1> [[WRONG]])
412 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
413 ; CHECK-NEXT: [[TMP15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP14]], i32 1)
414 ; CHECK-NEXT: [[TMP16:%.*]] = icmp ne i32 [[TMP15]], 0
415 ; CHECK-NEXT: br i1 [[TMP16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
416 ; CHECK: [[FOR_COND_CLEANUP]]:
417 ; CHECK-NEXT: ret void
418 ;
419 entry:
420 %cmp8 = icmp eq i32 %N, 0
421 %tmp8 = add i32 %N, 3
422 %tmp9 = lshr i32 %tmp8, 2
423 %tmp10 = shl nuw i32 %tmp9, 2
424 %tmp11 = add i32 %tmp10, -4
425 %tmp12 = lshr i32 %tmp11, 2
426 %tmp13 = add nuw nsw i32 %tmp12, 1
427 br i1 %cmp8, label %for.cond.cleanup, label %vector.ph
428
429 vector.ph: ; preds = %entry
430 %trip.count.minus.1 = add i32 %N, -1
431 %broadcast.splatinsert10 = insertelement <4 x i32> undef, i32 %trip.count.minus.1, i32 0
432 %broadcast.splat11 = shufflevector <4 x i32> %broadcast.splatinsert10, <4 x i32> undef, <4 x i32> zeroinitializer
433 %start = call i32 @llvm.start.loop.iterations.i32(i32 %tmp13)
434 br label %vector.body
435
436 vector.body: ; preds = %vector.body, %vector.ph
437 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
438 %tmp14 = phi i32 [ %start, %vector.ph ], [ %tmp15, %vector.body ]
439 %broadcast.splatinsert = insertelement <4 x i32> undef, i32 %index, i32 0
440 %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> undef, <4 x i32> zeroinitializer
441 %induction = add <4 x i32> %broadcast.splat, <i32 0, i32 1, i32 2, i32 3>
442 %tmp = getelementptr inbounds i32, ptr %a, i32 %index
443 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %N)
444 %wrong = icmp ult <4 x i32> %induction, %broadcast.splat11
445 %wide.masked.load = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
446 %tmp3 = getelementptr inbounds i32, ptr %b, i32 %index
447 %wide.masked.load12 = tail call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %tmp3, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
448 %tmp5 = mul nsw <4 x i32> %wide.masked.load12, %wide.masked.load
449 %tmp6 = getelementptr inbounds i32, ptr %c, i32 %index
450 tail call void @llvm.masked.store.v4i32.p0(<4 x i32> %tmp5, ptr %tmp6, i32 4, <4 x i1> %wrong)
451 %index.next = add i32 %index, 4
452 %tmp15 = call i32 @llvm.loop.decrement.reg.i32(i32 %tmp14, i32 1)
453 %tmp16 = icmp ne i32 %tmp15, 0
454 br i1 %tmp16, label %vector.body, label %for.cond.cleanup
455
456 for.cond.cleanup: ; preds = %vector.body, %entry
457 ret void
458 }
459
460 ; TODO: Multiple intrinsics not yet supported.
461 ; This is currently rejected, because if the vector body is unrolled, the step
462 ; is not what we expect:
463 ;
464 ; Step value 16 doesn't match vector width 4
465 ;
466 define dso_local void @interleave4(ptr noalias nocapture %A, ptr noalias nocapture readonly %B, ptr noalias nocapture readonly %C, i32 %N) local_unnamed_addr #0 {
467 ; CHECK-LABEL: define dso_local void @interleave4(
468 ; CHECK-SAME: ptr noalias captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias readonly captures(none) [[C:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
469 ; CHECK-NEXT: [[ENTRY:.*:]]
470 ; CHECK-NEXT: [[CMP8:%.*]] = icmp sgt i32 [[N]], 0
471 ; CHECK-NEXT: [[V0:%.*]] = add i32 [[N]], 15
472 ; CHECK-NEXT: [[V1:%.*]] = lshr i32 [[V0]], 4
473 ; CHECK-NEXT: [[V2:%.*]] = shl nuw i32 [[V1]], 4
474 ; CHECK-NEXT: [[V3:%.*]] = add i32 [[V2]], -16
475 ; CHECK-NEXT: [[V4:%.*]] = lshr i32 [[V3]], 4
476 ; CHECK-NEXT: [[V5:%.*]] = add nuw nsw i32 [[V4]], 1
477 ; CHECK-NEXT: br i1 [[CMP8]], label %[[VECTOR_PH:.*]], label %[[FOR_COND_CLEANUP:.*]]
478 ; CHECK: [[VECTOR_PH]]:
479 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, ptr [[A]], i32 8
480 ; CHECK-NEXT: [[SCEVGEP30:%.*]] = getelementptr i32, ptr [[C]], i32 8
481 ; CHECK-NEXT: [[SCEVGEP37:%.*]] = getelementptr i32, ptr [[B]], i32 8
482 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[V5]])
483 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
484 ; CHECK: [[VECTOR_BODY]]:
485 ; CHECK-NEXT: [[LSR_IV38:%.*]] = phi ptr [ [[SCEVGEP39:%.*]], %[[VECTOR_BODY]] ], [ [[SCEVGEP37]], %[[VECTOR_PH]] ]
486 ; CHECK-NEXT: [[LSR_IV31:%.*]] = phi ptr [ [[SCEVGEP32:%.*]], %[[VECTOR_BODY]] ], [ [[SCEVGEP30]], %[[VECTOR_PH]] ]
487 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi ptr [ [[SCEVGEP25:%.*]], %[[VECTOR_BODY]] ], [ [[SCEVGEP]], %[[VECTOR_PH]] ]
488 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[V14:%.*]], %[[VECTOR_BODY]] ]
489 ; CHECK-NEXT: [[V6:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[V15:%.*]], %[[VECTOR_BODY]] ]
490 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[INDEX]], i32 [[N]])
491 ; CHECK-NEXT: [[V7:%.*]] = add i32 [[INDEX]], 4
492 ; CHECK-NEXT: [[ACTIVE_LANE_MASK15:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[V7]], i32 [[N]])
493 ; CHECK-NEXT: [[V8:%.*]] = add i32 [[V7]], 4
494 ; CHECK-NEXT: [[ACTIVE_LANE_MASK16:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[V8]], i32 [[N]])
495 ; CHECK-NEXT: [[V9:%.*]] = add i32 [[V8]], 4
496 ; CHECK-NEXT: [[ACTIVE_LANE_MASK17:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[V9]], i32 [[N]])
497 ; CHECK-NEXT: [[SCEVGEP42:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV38]], i32 -2
498 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[SCEVGEP42]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
499 ; CHECK-NEXT: [[SCEVGEP43:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV38]], i32 -1
500 ; CHECK-NEXT: [[WIDE_MASKED_LOAD18:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[SCEVGEP43]], <4 x i1> [[ACTIVE_LANE_MASK15]], <4 x i32> undef)
501 ; CHECK-NEXT: [[WIDE_MASKED_LOAD19:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV38]], <4 x i1> [[ACTIVE_LANE_MASK16]], <4 x i32> undef)
502 ; CHECK-NEXT: [[SCEVGEP41:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV38]], i32 1
503 ; CHECK-NEXT: [[WIDE_MASKED_LOAD20:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[SCEVGEP41]], <4 x i1> [[ACTIVE_LANE_MASK17]], <4 x i32> undef)
504 ; CHECK-NEXT: [[SCEVGEP34:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV31]], i32 -2
505 ; CHECK-NEXT: [[WIDE_MASKED_LOAD21:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[SCEVGEP34]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
506 ; CHECK-NEXT: [[SCEVGEP35:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV31]], i32 -1
507 ; CHECK-NEXT: [[WIDE_MASKED_LOAD22:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[SCEVGEP35]], <4 x i1> [[ACTIVE_LANE_MASK15]], <4 x i32> undef)
508 ; CHECK-NEXT: [[WIDE_MASKED_LOAD23:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV31]], <4 x i1> [[ACTIVE_LANE_MASK16]], <4 x i32> undef)
509 ; CHECK-NEXT: [[SCEVGEP36:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV31]], i32 1
510 ; CHECK-NEXT: [[WIDE_MASKED_LOAD24:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[SCEVGEP36]], <4 x i1> [[ACTIVE_LANE_MASK17]], <4 x i32> undef)
511 ; CHECK-NEXT: [[V10:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD21]], [[WIDE_MASKED_LOAD]]
512 ; CHECK-NEXT: [[V11:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD22]], [[WIDE_MASKED_LOAD18]]
513 ; CHECK-NEXT: [[V12:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD23]], [[WIDE_MASKED_LOAD19]]
514 ; CHECK-NEXT: [[V13:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD24]], [[WIDE_MASKED_LOAD20]]
515 ; CHECK-NEXT: [[SCEVGEP27:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV]], i32 -2
516 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[V10]], ptr align 4 [[SCEVGEP27]], <4 x i1> [[ACTIVE_LANE_MASK]])
517 ; CHECK-NEXT: [[SCEVGEP28:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV]], i32 -1
518 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[V11]], ptr align 4 [[SCEVGEP28]], <4 x i1> [[ACTIVE_LANE_MASK15]])
519 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[V12]], ptr align 4 [[LSR_IV]], <4 x i1> [[ACTIVE_LANE_MASK16]])
520 ; CHECK-NEXT: [[SCEVGEP29:%.*]] = getelementptr <4 x i32>, ptr [[LSR_IV]], i32 1
521 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[V13]], ptr align 4 [[SCEVGEP29]], <4 x i1> [[ACTIVE_LANE_MASK17]])
522 ; CHECK-NEXT: [[SCEVGEP25]] = getelementptr i32, ptr [[LSR_IV]], i32 16
523 ; CHECK-NEXT: [[SCEVGEP32]] = getelementptr i32, ptr [[LSR_IV31]], i32 16
524 ; CHECK-NEXT: [[SCEVGEP39]] = getelementptr i32, ptr [[LSR_IV38]], i32 16
525 ; CHECK-NEXT: [[V14]] = add i32 [[V9]], 4
526 ; CHECK-NEXT: [[V15]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[V6]], i32 1)
527 ; CHECK-NEXT: [[V16:%.*]] = icmp ne i32 [[V15]], 0
528 ; CHECK-NEXT: br i1 [[V16]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
529 ; CHECK: [[FOR_COND_CLEANUP]]:
530 ; CHECK-NEXT: ret void
531 ;
532 entry:
533 %cmp8 = icmp sgt i32 %N, 0
534 %v0 = add i32 %N, 15
535 %v1 = lshr i32 %v0, 4
536 %v2 = shl nuw i32 %v1, 4
537 %v3 = add i32 %v2, -16
538 %v4 = lshr i32 %v3, 4
539 %v5 = add nuw nsw i32 %v4, 1
540 br i1 %cmp8, label %vector.ph, label %for.cond.cleanup
541
542
543 vector.ph:
544 %scevgep = getelementptr i32, ptr %A, i32 8
545 %scevgep30 = getelementptr i32, ptr %C, i32 8
546 %scevgep37 = getelementptr i32, ptr %B, i32 8
547 %start = call i32 @llvm.start.loop.iterations.i32(i32 %v5)
548 br label %vector.body
549
550 vector.body:
551 %lsr.iv38 = phi ptr [ %scevgep39, %vector.body ], [ %scevgep37, %vector.ph ]
552 %lsr.iv31 = phi ptr [ %scevgep32, %vector.body ], [ %scevgep30, %vector.ph ]
553 %lsr.iv = phi ptr [ %scevgep25, %vector.body ], [ %scevgep, %vector.ph ]
554 %index = phi i32 [ 0, %vector.ph ], [ %v14, %vector.body ]
555 %v6 = phi i32 [ %start, %vector.ph ], [ %v15, %vector.body ]
556 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %N)
557 %v7 = add i32 %index, 4
558 %active.lane.mask15 = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %v7, i32 %N)
559 %v8 = add i32 %v7, 4
560 %active.lane.mask16 = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %v8, i32 %N)
561 %v9 = add i32 %v8, 4
562 %active.lane.mask17 = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %v9, i32 %N)
563 %scevgep42 = getelementptr <4 x i32>, ptr %lsr.iv38, i32 -2
564 %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %scevgep42, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
565 %scevgep43 = getelementptr <4 x i32>, ptr %lsr.iv38, i32 -1
566 %wide.masked.load18 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr nonnull %scevgep43, i32 4, <4 x i1> %active.lane.mask15, <4 x i32> undef)
567 %wide.masked.load19 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr nonnull %lsr.iv38, i32 4, <4 x i1> %active.lane.mask16, <4 x i32> undef)
568 %scevgep41 = getelementptr <4 x i32>, ptr %lsr.iv38, i32 1
569 %wide.masked.load20 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr nonnull %scevgep41, i32 4, <4 x i1> %active.lane.mask17, <4 x i32> undef)
570 %scevgep34 = getelementptr <4 x i32>, ptr %lsr.iv31, i32 -2
571 %wide.masked.load21 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %scevgep34, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
572 %scevgep35 = getelementptr <4 x i32>, ptr %lsr.iv31, i32 -1
573 %wide.masked.load22 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr nonnull %scevgep35, i32 4, <4 x i1> %active.lane.mask15, <4 x i32> undef)
574 %wide.masked.load23 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr nonnull %lsr.iv31, i32 4, <4 x i1> %active.lane.mask16, <4 x i32> undef)
575 %scevgep36 = getelementptr <4 x i32>, ptr %lsr.iv31, i32 1
576 %wide.masked.load24 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr nonnull %scevgep36, i32 4, <4 x i1> %active.lane.mask17, <4 x i32> undef)
577 %v10 = add nsw <4 x i32> %wide.masked.load21, %wide.masked.load
578 %v11 = add nsw <4 x i32> %wide.masked.load22, %wide.masked.load18
579 %v12 = add nsw <4 x i32> %wide.masked.load23, %wide.masked.load19
580 %v13 = add nsw <4 x i32> %wide.masked.load24, %wide.masked.load20
581 %scevgep27 = getelementptr <4 x i32>, ptr %lsr.iv, i32 -2
582 call void @llvm.masked.store.v4i32.p0(<4 x i32> %v10, ptr %scevgep27, i32 4, <4 x i1> %active.lane.mask)
583 %scevgep28 = getelementptr <4 x i32>, ptr %lsr.iv, i32 -1
584 call void @llvm.masked.store.v4i32.p0(<4 x i32> %v11, ptr %scevgep28, i32 4, <4 x i1> %active.lane.mask15)
585 call void @llvm.masked.store.v4i32.p0(<4 x i32> %v12, ptr %lsr.iv, i32 4, <4 x i1> %active.lane.mask16)
586 %scevgep29 = getelementptr <4 x i32>, ptr %lsr.iv, i32 1
587 call void @llvm.masked.store.v4i32.p0(<4 x i32> %v13, ptr %scevgep29, i32 4, <4 x i1> %active.lane.mask17)
588 %scevgep25 = getelementptr i32, ptr %lsr.iv, i32 16
589 %scevgep32 = getelementptr i32, ptr %lsr.iv31, i32 16
590 %scevgep39 = getelementptr i32, ptr %lsr.iv38, i32 16
591 %v14 = add i32 %v9, 4
592 %v15 = call i32 @llvm.loop.decrement.reg.i32(i32 %v6, i32 1)
593 %v16 = icmp ne i32 %v15, 0
594 br i1 %v16, label %vector.body, label %for.cond.cleanup
595
596 for.cond.cleanup:
597 ret void
598 }
599
600 define dso_local void @const_expected_in_set_loop(ptr noalias nocapture %A, ptr noalias nocapture readonly %B, ptr noalias nocapture readonly %C, i32 %N) local_unnamed_addr #0 {
601 ; CHECK-LABEL: define dso_local void @const_expected_in_set_loop(
602 ; CHECK-SAME: ptr noalias captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias readonly captures(none) [[C:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
603 ; CHECK-NEXT: [[ENTRY:.*:]]
604 ; CHECK-NEXT: [[CMP8:%.*]] = icmp sgt i32 [[N]], 0
605 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N]], 3
606 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP0]], 2
607 ; CHECK-NEXT: [[TMP2:%.*]] = shl nuw i32 [[TMP1]], 2
608 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], -4
609 ; CHECK-NEXT: [[TMP4:%.*]] = lshr i32 [[TMP3]], 2
610 ; CHECK-NEXT: [[TMP5:%.*]] = add nuw nsw i32 [[TMP4]], 1
611 ; CHECK-NEXT: br i1 [[CMP8]], label %[[VECTOR_PH:.*]], label %[[FOR_COND_CLEANUP:.*]]
612 ; CHECK: [[VECTOR_PH]]:
613 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP5]])
614 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
615 ; CHECK: [[VECTOR_BODY]]:
616 ; CHECK-NEXT: [[LSR_IV17:%.*]] = phi ptr [ [[SCEVGEP18:%.*]], %[[VECTOR_BODY]] ], [ [[A]], %[[VECTOR_PH]] ]
617 ; CHECK-NEXT: [[LSR_IV14:%.*]] = phi ptr [ [[SCEVGEP15:%.*]], %[[VECTOR_BODY]] ], [ [[C]], %[[VECTOR_PH]] ]
618 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi ptr [ [[SCEVGEP:%.*]], %[[VECTOR_BODY]] ], [ [[B]], %[[VECTOR_PH]] ]
619 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
620 ; CHECK-NEXT: [[TMP6:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP8:%.*]], %[[VECTOR_BODY]] ]
621 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[INDEX]], i32 42)
622 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
623 ; CHECK-NEXT: [[WIDE_MASKED_LOAD12:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV14]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
624 ; CHECK-NEXT: [[TMP7:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD12]], [[WIDE_MASKED_LOAD]]
625 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[TMP7]], ptr align 4 [[LSR_IV17]], <4 x i1> [[ACTIVE_LANE_MASK]])
626 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
627 ; CHECK-NEXT: [[SCEVGEP]] = getelementptr i32, ptr [[LSR_IV]], i32 4
628 ; CHECK-NEXT: [[SCEVGEP15]] = getelementptr i32, ptr [[LSR_IV14]], i32 4
629 ; CHECK-NEXT: [[SCEVGEP18]] = getelementptr i32, ptr [[LSR_IV17]], i32 4
630 ; CHECK-NEXT: [[TMP8]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP6]], i32 1)
631 ; CHECK-NEXT: [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
632 ; CHECK-NEXT: br i1 [[TMP9]], label %[[VECTOR_BODY]], label %[[FOR_COND_CLEANUP]]
633 ; CHECK: [[FOR_COND_CLEANUP]]:
634 ; CHECK-NEXT: ret void
635 ;
636 entry:
637 %cmp8 = icmp sgt i32 %N, 0
638 %0 = add i32 %N, 3
639 %1 = lshr i32 %0, 2
640 %2 = shl nuw i32 %1, 2
641 %3 = add i32 %2, -4
642 %4 = lshr i32 %3, 2
643 %5 = add nuw nsw i32 %4, 1
644 br i1 %cmp8, label %vector.ph, label %for.cond.cleanup
645
646 vector.ph:
647 %start = call i32 @llvm.start.loop.iterations.i32(i32 %5)
648 br label %vector.body
649
650 vector.body: ; preds = %vector.body, %vector.ph
651 %lsr.iv17 = phi ptr [ %scevgep18, %vector.body ], [ %A, %vector.ph ]
652 %lsr.iv14 = phi ptr [ %scevgep15, %vector.body ], [ %C, %vector.ph ]
653 %lsr.iv = phi ptr [ %scevgep, %vector.body ], [ %B, %vector.ph ]
654 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
655 %6 = phi i32 [ %start, %vector.ph ], [ %8, %vector.body ]
656 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 42)
657 %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %lsr.iv, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
658 %wide.masked.load12 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %lsr.iv14, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
659 %7 = add nsw <4 x i32> %wide.masked.load12, %wide.masked.load
660 call void @llvm.masked.store.v4i32.p0(<4 x i32> %7, ptr %lsr.iv17, i32 4, <4 x i1> %active.lane.mask)
661 %index.next = add i32 %index, 4
662 %scevgep = getelementptr i32, ptr %lsr.iv, i32 4
663 %scevgep15 = getelementptr i32, ptr %lsr.iv14, i32 4
664 %scevgep18 = getelementptr i32, ptr %lsr.iv17, i32 4
665 %8 = call i32 @llvm.loop.decrement.reg.i32(i32 %6, i32 1)
666 %9 = icmp ne i32 %8, 0
667 br i1 %9, label %vector.body, label %for.cond.cleanup
668
669 for.cond.cleanup: ; preds = %vector.body, %entry
670 ret void
671 }
672
673 define dso_local void @tripcount_arg_not_invariant(ptr noalias nocapture %A, ptr noalias nocapture readonly %B, ptr noalias nocapture readonly %C, i32 %N) local_unnamed_addr #0 {
674 ; CHECK-LABEL: define dso_local void @tripcount_arg_not_invariant(
675 ; CHECK-SAME: ptr noalias captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias readonly captures(none) [[C:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
676 ; CHECK-NEXT: [[ENTRY:.*:]]
677 ; CHECK-NEXT: [[CMP8:%.*]] = icmp sgt i32 [[N]], 0
678 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N]], 3
679 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP0]], 2
680 ; CHECK-NEXT: [[TMP2:%.*]] = shl nuw i32 [[TMP1]], 2
681 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], -4
682 ; CHECK-NEXT: [[TMP4:%.*]] = lshr i32 [[TMP3]], 2
683 ; CHECK-NEXT: [[TMP5:%.*]] = add nuw nsw i32 [[TMP4]], 1
684 ; CHECK-NEXT: br i1 [[CMP8]], label %[[VECTOR_PH:.*]], label %[[FOR_COND_CLEANUP:.*]]
685 ; CHECK: [[VECTOR_PH]]:
686 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP5]])
687 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
688 ; CHECK: [[VECTOR_BODY]]:
689 ; CHECK-NEXT: [[LSR_IV17:%.*]] = phi ptr [ [[SCEVGEP18:%.*]], %[[VECTOR_BODY]] ], [ [[A]], %[[VECTOR_PH]] ]
690 ; CHECK-NEXT: [[LSR_IV14:%.*]] = phi ptr [ [[SCEVGEP15:%.*]], %[[VECTOR_BODY]] ], [ [[C]], %[[VECTOR_PH]] ]
691 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi ptr [ [[SCEVGEP:%.*]], %[[VECTOR_BODY]] ], [ [[B]], %[[VECTOR_PH]] ]
692 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
693 ; CHECK-NEXT: [[TMP6:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP8:%.*]], %[[VECTOR_BODY]] ]
694 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[INDEX]], i32 [[INDEX]])
695 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
696 ; CHECK-NEXT: [[WIDE_MASKED_LOAD12:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV14]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
697 ; CHECK-NEXT: [[TMP7:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD12]], [[WIDE_MASKED_LOAD]]
698 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[TMP7]], ptr align 4 [[LSR_IV17]], <4 x i1> [[ACTIVE_LANE_MASK]])
699 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
700 ; CHECK-NEXT: [[SCEVGEP]] = getelementptr i32, ptr [[LSR_IV]], i32 4
701 ; CHECK-NEXT: [[SCEVGEP15]] = getelementptr i32, ptr [[LSR_IV14]], i32 4
702 ; CHECK-NEXT: [[SCEVGEP18]] = getelementptr i32, ptr [[LSR_IV17]], i32 4
703 ; CHECK-NEXT: [[TMP8]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP6]], i32 1)
704 ; CHECK-NEXT: [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
705 ; CHECK-NEXT: br i1 [[TMP9]], label %[[VECTOR_BODY]], label %[[VECTOR_PH]]
706 ; CHECK: [[FOR_COND_CLEANUP]]:
707 ; CHECK-NEXT: ret void
708 ;
709 entry:
710 %cmp8 = icmp sgt i32 %N, 0
711 %0 = add i32 %N, 3
712 %1 = lshr i32 %0, 2
713 %2 = shl nuw i32 %1, 2
714 %3 = add i32 %2, -4
715 %4 = lshr i32 %3, 2
716 %5 = add nuw nsw i32 %4, 1
717 br i1 %cmp8, label %vector.ph, label %for.cond.cleanup
718
719 vector.ph: ; preds = %entry
720 %start = call i32 @llvm.start.loop.iterations.i32(i32 %5)
721 br label %vector.body
722
723 vector.body: ; preds = %vector.body, %vector.ph
724 %lsr.iv17 = phi ptr [ %scevgep18, %vector.body ], [ %A, %vector.ph ]
725 %lsr.iv14 = phi ptr [ %scevgep15, %vector.body ], [ %C, %vector.ph ]
726 %lsr.iv = phi ptr [ %scevgep, %vector.body ], [ %B, %vector.ph ]
727 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
728 %6 = phi i32 [ %start, %vector.ph ], [ %8, %vector.body ]
729
730 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %index)
731 %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %lsr.iv, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
732 %wide.masked.load12 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %lsr.iv14, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
733 %7 = add nsw <4 x i32> %wide.masked.load12, %wide.masked.load
734 call void @llvm.masked.store.v4i32.p0(<4 x i32> %7, ptr %lsr.iv17, i32 4, <4 x i1> %active.lane.mask)
735 %index.next = add i32 %index, 4
736 %scevgep = getelementptr i32, ptr %lsr.iv, i32 4
737 %scevgep15 = getelementptr i32, ptr %lsr.iv14, i32 4
738 %scevgep18 = getelementptr i32, ptr %lsr.iv17, i32 4
739 %8 = call i32 @llvm.loop.decrement.reg.i32(i32 %6, i32 1)
740 %9 = icmp ne i32 %8, 0
741 ;br i1 %9, label %vector.body, label %for.cond.cleanup
742 br i1 %9, label %vector.body, label %vector.ph
743
744 for.cond.cleanup: ; preds = %vector.body, %entry
745 ret void
746 }
747
748 define dso_local void @addrec_base_not_zero(ptr noalias nocapture %A, ptr noalias nocapture readonly %B, ptr noalias nocapture readonly %C, i32 %N) local_unnamed_addr #0 {
749 ; CHECK-LABEL: define dso_local void @addrec_base_not_zero(
750 ; CHECK-SAME: ptr noalias captures(none) [[A:%.*]], ptr noalias readonly captures(none) [[B:%.*]], ptr noalias readonly captures(none) [[C:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0]] {
751 ; CHECK-NEXT: [[ENTRY:.*:]]
752 ; CHECK-NEXT: [[CMP8:%.*]] = icmp sgt i32 [[N]], 0
753 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[N]], 3
754 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP0]], 2
755 ; CHECK-NEXT: [[TMP2:%.*]] = shl nuw i32 [[TMP1]], 2
756 ; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], -4
757 ; CHECK-NEXT: [[TMP4:%.*]] = lshr i32 [[TMP3]], 2
758 ; CHECK-NEXT: [[TMP5:%.*]] = add nuw nsw i32 [[TMP4]], 1
759 ; CHECK-NEXT: br i1 [[CMP8]], label %[[VECTOR_PH:.*]], label %[[FOR_COND_CLEANUP:.*]]
760 ; CHECK: [[VECTOR_PH]]:
761 ; CHECK-NEXT: [[START:%.*]] = call i32 @llvm.start.loop.iterations.i32(i32 [[TMP5]])
762 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
763 ; CHECK: [[VECTOR_BODY]]:
764 ; CHECK-NEXT: [[LSR_IV17:%.*]] = phi ptr [ [[SCEVGEP18:%.*]], %[[VECTOR_BODY]] ], [ [[A]], %[[VECTOR_PH]] ]
765 ; CHECK-NEXT: [[LSR_IV14:%.*]] = phi ptr [ [[SCEVGEP15:%.*]], %[[VECTOR_BODY]] ], [ [[C]], %[[VECTOR_PH]] ]
766 ; CHECK-NEXT: [[LSR_IV:%.*]] = phi ptr [ [[SCEVGEP:%.*]], %[[VECTOR_BODY]] ], [ [[B]], %[[VECTOR_PH]] ]
767 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 1, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
768 ; CHECK-NEXT: [[TMP6:%.*]] = phi i32 [ [[START]], %[[VECTOR_PH]] ], [ [[TMP8:%.*]], %[[VECTOR_BODY]] ]
769 ; CHECK-NEXT: [[ACTIVE_LANE_MASK:%.*]] = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 [[INDEX]], i32 [[N]])
770 ; CHECK-NEXT: [[WIDE_MASKED_LOAD:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
771 ; CHECK-NEXT: [[WIDE_MASKED_LOAD12:%.*]] = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr align 4 [[LSR_IV14]], <4 x i1> [[ACTIVE_LANE_MASK]], <4 x i32> undef)
772 ; CHECK-NEXT: [[TMP7:%.*]] = add nsw <4 x i32> [[WIDE_MASKED_LOAD12]], [[WIDE_MASKED_LOAD]]
773 ; CHECK-NEXT: call void @llvm.masked.store.v4i32.p0(<4 x i32> [[TMP7]], ptr align 4 [[LSR_IV17]], <4 x i1> [[ACTIVE_LANE_MASK]])
774 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
775 ; CHECK-NEXT: [[SCEVGEP]] = getelementptr i32, ptr [[LSR_IV]], i32 4
776 ; CHECK-NEXT: [[SCEVGEP15]] = getelementptr i32, ptr [[LSR_IV14]], i32 4
777 ; CHECK-NEXT: [[SCEVGEP18]] = getelementptr i32, ptr [[LSR_IV17]], i32 4
778 ; CHECK-NEXT: [[TMP8]] = call i32 @llvm.loop.decrement.reg.i32(i32 [[TMP6]], i32 1)
779 ; CHECK-NEXT: [[TMP9:%.*]] = icmp ne i32 [[TMP8]], 0
780 ; CHECK-NEXT: br i1 [[TMP9]], label %[[VECTOR_BODY]], label %[[VECTOR_PH]]
781 ; CHECK: [[FOR_COND_CLEANUP]]:
782 ; CHECK-NEXT: ret void
783 ;
784 entry:
785 %cmp8 = icmp sgt i32 %N, 0
786 %0 = add i32 %N, 3
787 %1 = lshr i32 %0, 2
788 %2 = shl nuw i32 %1, 2
789 %3 = add i32 %2, -4
790 %4 = lshr i32 %3, 2
791 %5 = add nuw nsw i32 %4, 1
792 br i1 %cmp8, label %vector.ph, label %for.cond.cleanup
793
794 vector.ph: ; preds = %entry
795 %start = call i32 @llvm.start.loop.iterations.i32(i32 %5)
796 br label %vector.body
797
798 vector.body: ; preds = %vector.body, %vector.ph
799 %lsr.iv17 = phi ptr [ %scevgep18, %vector.body ], [ %A, %vector.ph ]
800 %lsr.iv14 = phi ptr [ %scevgep15, %vector.body ], [ %C, %vector.ph ]
801 %lsr.iv = phi ptr [ %scevgep, %vector.body ], [ %B, %vector.ph ]
802
803 ; AddRec base is not 0:
804 %index = phi i32 [ 1, %vector.ph ], [ %index.next, %vector.body ]
805
806 %6 = phi i32 [ %start, %vector.ph ], [ %8, %vector.body ]
807 %active.lane.mask = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %index, i32 %N)
808 %wide.masked.load = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %lsr.iv, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
809 %wide.masked.load12 = call <4 x i32> @llvm.masked.load.v4i32.p0(ptr %lsr.iv14, i32 4, <4 x i1> %active.lane.mask, <4 x i32> undef)
810 %7 = add nsw <4 x i32> %wide.masked.load12, %wide.masked.load
811 call void @llvm.masked.store.v4i32.p0(<4 x i32> %7, ptr %lsr.iv17, i32 4, <4 x i1> %active.lane.mask)
812 %index.next = add i32 %index, 4
813 %scevgep = getelementptr i32, ptr %lsr.iv, i32 4
814 %scevgep15 = getelementptr i32, ptr %lsr.iv14, i32 4
815 %scevgep18 = getelementptr i32, ptr %lsr.iv17, i32 4
816 %8 = call i32 @llvm.loop.decrement.reg.i32(i32 %6, i32 1)
817 %9 = icmp ne i32 %8, 0
818 ;br i1 %9, label %vector.body, label %for.cond.cleanup
819 br i1 %9, label %vector.body, label %vector.ph
820
821 for.cond.cleanup: ; preds = %vector.body, %entry
822 ret void
823 }
824
825
826 declare <16 x i8> @llvm.masked.load.v16i8.p0(ptr, i32 immarg, <16 x i1>, <16 x i8>)
827 declare void @llvm.masked.store.v16i8.p0(<16 x i8>, ptr, i32 immarg, <16 x i1>)
828 declare <8 x i16> @llvm.masked.load.v8i16.p0(ptr, i32 immarg, <8 x i1>, <8 x i16>)
829 declare void @llvm.masked.store.v8i16.p0(<8 x i16>, ptr, i32 immarg, <8 x i1>)
830 declare <4 x i32> @llvm.masked.load.v4i32.p0(ptr, i32 immarg, <4 x i1>, <4 x i32>)
831 declare void @llvm.masked.store.v2i64.p0(<2 x i64>, ptr, i32 immarg, <2 x i1>)
832 declare <2 x i64> @llvm.masked.load.v2i64.p0(ptr, i32 immarg, <2 x i1>, <2 x i64>)
833 declare void @llvm.masked.store.v4i32.p0(<4 x i32>, ptr, i32 immarg, <4 x i1>)
834 declare i32 @llvm.start.loop.iterations.i32(i32)
835 declare i32 @llvm.loop.decrement.reg.i32(i32, i32)
836 declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32, i32)
837 declare <8 x i1> @llvm.get.active.lane.mask.v8i1.i32(i32, i32)
838 declare <16 x i1> @llvm.get.active.lane.mask.v16i1.i32(i32, i32)