srem-vector-lkk.ll
11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
define <4 x i16> @fold_srem_vec_1(<4 x i16> %x) {
; CHECK-LABEL: fold_srem_vec_1:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w9, #63421
; CHECK-NEXT: mov w12, #33437
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: smov w8, v0.h[1]
; CHECK-NEXT: movk w9, #31710, lsl #16
; CHECK-NEXT: smov w11, v0.h[2]
; CHECK-NEXT: movk w12, #21399, lsl #16
; CHECK-NEXT: smull x12, w11, w12
; CHECK-NEXT: smull x9, w8, w9
; CHECK-NEXT: lsr x13, x12, #63
; CHECK-NEXT: asr x12, x12, #37
; CHECK-NEXT: lsr x9, x9, #32
; CHECK-NEXT: add w12, w12, w13
; CHECK-NEXT: mov w13, #98
; CHECK-NEXT: sub w9, w9, w8
; CHECK-NEXT: msub w11, w12, w13, w11
; CHECK-NEXT: asr w13, w9, #6
; CHECK-NEXT: add w9, w13, w9, lsr #31
; CHECK-NEXT: mov w13, #37253
; CHECK-NEXT: mov w10, #-124
; CHECK-NEXT: smov w12, v0.h[0]
; CHECK-NEXT: movk w13, #44150, lsl #16
; CHECK-NEXT: msub w8, w9, w10, w8
; CHECK-NEXT: smull x10, w12, w13
; CHECK-NEXT: lsr x10, x10, #32
; CHECK-NEXT: add w10, w10, w12
; CHECK-NEXT: asr w13, w10, #6
; CHECK-NEXT: mov w9, #95
; CHECK-NEXT: add w10, w13, w10, lsr #31
; CHECK-NEXT: msub w9, w10, w9, w12
; CHECK-NEXT: mov w10, #63249
; CHECK-NEXT: smov w13, v0.h[3]
; CHECK-NEXT: movk w10, #48808, lsl #16
; CHECK-NEXT: smull x10, w13, w10
; CHECK-NEXT: lsr x12, x10, #63
; CHECK-NEXT: asr x10, x10, #40
; CHECK-NEXT: fmov s0, w9
; CHECK-NEXT: add w10, w10, w12
; CHECK-NEXT: mov v0.h[1], w8
; CHECK-NEXT: mov w8, #-1003
; CHECK-NEXT: mov v0.h[2], w11
; CHECK-NEXT: msub w8, w10, w8, w13
; CHECK-NEXT: mov v0.h[3], w8
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-NEXT: ret
%1 = srem <4 x i16> %x, <i16 95, i16 -124, i16 98, i16 -1003>
ret <4 x i16> %1
}
define <4 x i16> @fold_srem_vec_2(<4 x i16> %x) {
; CHECK-LABEL: fold_srem_vec_2:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w9, #37253
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: smov w8, v0.h[1]
; CHECK-NEXT: movk w9, #44150, lsl #16
; CHECK-NEXT: smov w10, v0.h[0]
; CHECK-NEXT: smull x13, w8, w9
; CHECK-NEXT: smov w11, v0.h[2]
; CHECK-NEXT: smull x14, w10, w9
; CHECK-NEXT: lsr x13, x13, #32
; CHECK-NEXT: smov w12, v0.h[3]
; CHECK-NEXT: smull x15, w11, w9
; CHECK-NEXT: lsr x14, x14, #32
; CHECK-NEXT: add w13, w13, w8
; CHECK-NEXT: smull x9, w12, w9
; CHECK-NEXT: lsr x15, x15, #32
; CHECK-NEXT: add w14, w14, w10
; CHECK-NEXT: asr w16, w13, #6
; CHECK-NEXT: lsr x9, x9, #32
; CHECK-NEXT: add w15, w15, w11
; CHECK-NEXT: add w13, w16, w13, lsr #31
; CHECK-NEXT: asr w16, w14, #6
; CHECK-NEXT: add w9, w9, w12
; CHECK-NEXT: add w14, w16, w14, lsr #31
; CHECK-NEXT: asr w16, w15, #6
; CHECK-NEXT: add w15, w16, w15, lsr #31
; CHECK-NEXT: asr w16, w9, #6
; CHECK-NEXT: add w9, w16, w9, lsr #31
; CHECK-NEXT: mov w16, #95
; CHECK-NEXT: msub w10, w14, w16, w10
; CHECK-NEXT: msub w8, w13, w16, w8
; CHECK-NEXT: fmov s0, w10
; CHECK-NEXT: msub w11, w15, w16, w11
; CHECK-NEXT: mov v0.h[1], w8
; CHECK-NEXT: mov v0.h[2], w11
; CHECK-NEXT: msub w8, w9, w16, w12
; CHECK-NEXT: mov v0.h[3], w8
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-NEXT: ret
%1 = srem <4 x i16> %x, <i16 95, i16 95, i16 95, i16 95>
ret <4 x i16> %1
}
; Don't fold if we can combine srem with sdiv.
define <4 x i16> @combine_srem_sdiv(<4 x i16> %x) {
; CHECK-LABEL: combine_srem_sdiv:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w8, #37253
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: movk w8, #44150, lsl #16
; CHECK-NEXT: smov w9, v0.h[1]
; CHECK-NEXT: smov w10, v0.h[0]
; CHECK-NEXT: smull x13, w9, w8
; CHECK-NEXT: smov w11, v0.h[2]
; CHECK-NEXT: smull x14, w10, w8
; CHECK-NEXT: lsr x13, x13, #32
; CHECK-NEXT: smov w12, v0.h[3]
; CHECK-NEXT: smull x15, w11, w8
; CHECK-NEXT: lsr x14, x14, #32
; CHECK-NEXT: add w13, w13, w9
; CHECK-NEXT: smull x8, w12, w8
; CHECK-NEXT: lsr x15, x15, #32
; CHECK-NEXT: add w14, w14, w10
; CHECK-NEXT: asr w16, w13, #6
; CHECK-NEXT: lsr x8, x8, #32
; CHECK-NEXT: add w15, w15, w11
; CHECK-NEXT: add w13, w16, w13, lsr #31
; CHECK-NEXT: asr w16, w14, #6
; CHECK-NEXT: add w8, w8, w12
; CHECK-NEXT: add w14, w16, w14, lsr #31
; CHECK-NEXT: asr w16, w15, #6
; CHECK-NEXT: add w15, w16, w15, lsr #31
; CHECK-NEXT: asr w16, w8, #6
; CHECK-NEXT: add w8, w16, w8, lsr #31
; CHECK-NEXT: mov w16, #95
; CHECK-NEXT: msub w10, w14, w16, w10
; CHECK-NEXT: msub w9, w13, w16, w9
; CHECK-NEXT: fmov s0, w14
; CHECK-NEXT: fmov s1, w10
; CHECK-NEXT: msub w11, w15, w16, w11
; CHECK-NEXT: mov v0.h[1], w13
; CHECK-NEXT: mov v1.h[1], w9
; CHECK-NEXT: msub w12, w8, w16, w12
; CHECK-NEXT: mov v0.h[2], w15
; CHECK-NEXT: mov v1.h[2], w11
; CHECK-NEXT: mov v1.h[3], w12
; CHECK-NEXT: mov v0.h[3], w8
; CHECK-NEXT: add v0.4h, v1.4h, v0.4h
; CHECK-NEXT: ret
%1 = srem <4 x i16> %x, <i16 95, i16 95, i16 95, i16 95>
%2 = sdiv <4 x i16> %x, <i16 95, i16 95, i16 95, i16 95>
%3 = add <4 x i16> %1, %2
ret <4 x i16> %3
}
; Don't fold for divisors that are a power of two.
define <4 x i16> @dont_fold_srem_power_of_two(<4 x i16> %x) {
; CHECK-LABEL: dont_fold_srem_power_of_two:
; CHECK: // %bb.0:
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: smov w8, v0.h[1]
; CHECK-NEXT: add w12, w8, #31 // =31
; CHECK-NEXT: cmp w8, #0 // =0
; CHECK-NEXT: mov w11, #37253
; CHECK-NEXT: csel w12, w12, w8, lt
; CHECK-NEXT: smov w9, v0.h[0]
; CHECK-NEXT: smov w10, v0.h[3]
; CHECK-NEXT: movk w11, #44150, lsl #16
; CHECK-NEXT: and w12, w12, #0xffffffe0
; CHECK-NEXT: sub w8, w8, w12
; CHECK-NEXT: add w12, w9, #63 // =63
; CHECK-NEXT: smull x11, w10, w11
; CHECK-NEXT: cmp w9, #0 // =0
; CHECK-NEXT: lsr x11, x11, #32
; CHECK-NEXT: csel w12, w12, w9, lt
; CHECK-NEXT: add w11, w11, w10
; CHECK-NEXT: and w12, w12, #0xffffffc0
; CHECK-NEXT: sub w9, w9, w12
; CHECK-NEXT: asr w12, w11, #6
; CHECK-NEXT: add w11, w12, w11, lsr #31
; CHECK-NEXT: smov w12, v0.h[2]
; CHECK-NEXT: fmov s0, w9
; CHECK-NEXT: add w9, w12, #7 // =7
; CHECK-NEXT: cmp w12, #0 // =0
; CHECK-NEXT: csel w9, w9, w12, lt
; CHECK-NEXT: and w9, w9, #0xfffffff8
; CHECK-NEXT: sub w9, w12, w9
; CHECK-NEXT: mov v0.h[1], w8
; CHECK-NEXT: mov w8, #95
; CHECK-NEXT: mov v0.h[2], w9
; CHECK-NEXT: msub w8, w11, w8, w10
; CHECK-NEXT: mov v0.h[3], w8
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-NEXT: ret
%1 = srem <4 x i16> %x, <i16 64, i16 32, i16 8, i16 95>
ret <4 x i16> %1
}
; Don't fold if the divisor is one.
define <4 x i16> @dont_fold_srem_one(<4 x i16> %x) {
; CHECK-LABEL: dont_fold_srem_one:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w9, #17097
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: smov w8, v0.h[2]
; CHECK-NEXT: movk w9, #45590, lsl #16
; CHECK-NEXT: smull x9, w8, w9
; CHECK-NEXT: lsr x9, x9, #32
; CHECK-NEXT: add w9, w9, w8
; CHECK-NEXT: asr w12, w9, #4
; CHECK-NEXT: add w9, w12, w9, lsr #31
; CHECK-NEXT: mov w12, #30865
; CHECK-NEXT: mov w10, #23
; CHECK-NEXT: smov w11, v0.h[1]
; CHECK-NEXT: movk w12, #51306, lsl #16
; CHECK-NEXT: msub w8, w9, w10, w8
; CHECK-NEXT: smull x10, w11, w12
; CHECK-NEXT: lsr x10, x10, #32
; CHECK-NEXT: add w10, w10, w11
; CHECK-NEXT: asr w12, w10, #9
; CHECK-NEXT: mov w9, #654
; CHECK-NEXT: add w10, w12, w10, lsr #31
; CHECK-NEXT: msub w9, w10, w9, w11
; CHECK-NEXT: mov w10, #47143
; CHECK-NEXT: smov w12, v0.h[3]
; CHECK-NEXT: movk w10, #24749, lsl #16
; CHECK-NEXT: smull x10, w12, w10
; CHECK-NEXT: lsr x11, x10, #63
; CHECK-NEXT: asr x10, x10, #43
; CHECK-NEXT: movi d0, #0000000000000000
; CHECK-NEXT: add w10, w10, w11
; CHECK-NEXT: mov v0.h[1], w9
; CHECK-NEXT: mov w9, #5423
; CHECK-NEXT: mov v0.h[2], w8
; CHECK-NEXT: msub w8, w10, w9, w12
; CHECK-NEXT: mov v0.h[3], w8
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-NEXT: ret
%1 = srem <4 x i16> %x, <i16 1, i16 654, i16 23, i16 5423>
ret <4 x i16> %1
}
; Don't fold if the divisor is 2^15.
define <4 x i16> @dont_fold_srem_i16_smax(<4 x i16> %x) {
; CHECK-LABEL: dont_fold_srem_i16_smax:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w10, #17097
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: smov w9, v0.h[2]
; CHECK-NEXT: movk w10, #45590, lsl #16
; CHECK-NEXT: smull x10, w9, w10
; CHECK-NEXT: lsr x10, x10, #32
; CHECK-NEXT: add w10, w10, w9
; CHECK-NEXT: asr w12, w10, #4
; CHECK-NEXT: mov w11, #23
; CHECK-NEXT: add w10, w12, w10, lsr #31
; CHECK-NEXT: msub w9, w10, w11, w9
; CHECK-NEXT: mov w10, #47143
; CHECK-NEXT: smov w12, v0.h[3]
; CHECK-NEXT: movk w10, #24749, lsl #16
; CHECK-NEXT: smull x10, w12, w10
; CHECK-NEXT: lsr x11, x10, #63
; CHECK-NEXT: asr x10, x10, #43
; CHECK-NEXT: smov w8, v0.h[1]
; CHECK-NEXT: add w10, w10, w11
; CHECK-NEXT: mov w11, #32767
; CHECK-NEXT: add w11, w8, w11
; CHECK-NEXT: cmp w8, #0 // =0
; CHECK-NEXT: csel w11, w11, w8, lt
; CHECK-NEXT: and w11, w11, #0xffff8000
; CHECK-NEXT: sub w8, w8, w11
; CHECK-NEXT: movi d0, #0000000000000000
; CHECK-NEXT: mov v0.h[1], w8
; CHECK-NEXT: mov w8, #5423
; CHECK-NEXT: mov v0.h[2], w9
; CHECK-NEXT: msub w8, w10, w8, w12
; CHECK-NEXT: mov v0.h[3], w8
; CHECK-NEXT: // kill: def $d0 killed $d0 killed $q0
; CHECK-NEXT: ret
%1 = srem <4 x i16> %x, <i16 1, i16 32768, i16 23, i16 5423>
ret <4 x i16> %1
}
; Don't fold i64 srem.
define <4 x i64> @dont_fold_srem_i64(<4 x i64> %x) {
; CHECK-LABEL: dont_fold_srem_i64:
; CHECK: // %bb.0:
; CHECK-NEXT: mov x9, #6055
; CHECK-NEXT: movk x9, #58853, lsl #16
; CHECK-NEXT: movk x9, #47142, lsl #32
; CHECK-NEXT: mov x8, v1.d[1]
; CHECK-NEXT: movk x9, #24749, lsl #48
; CHECK-NEXT: smulh x9, x8, x9
; CHECK-NEXT: asr x12, x9, #11
; CHECK-NEXT: mov w10, #5423
; CHECK-NEXT: add x9, x12, x9, lsr #63
; CHECK-NEXT: msub x8, x9, x10, x8
; CHECK-NEXT: mov x9, #21445
; CHECK-NEXT: movk x9, #1603, lsl #16
; CHECK-NEXT: movk x9, #15432, lsl #32
; CHECK-NEXT: mov x12, v0.d[1]
; CHECK-NEXT: movk x9, #25653, lsl #48
; CHECK-NEXT: smulh x9, x12, x9
; CHECK-NEXT: asr x10, x9, #8
; CHECK-NEXT: add x9, x10, x9, lsr #63
; CHECK-NEXT: mov w10, #654
; CHECK-NEXT: msub x9, x9, x10, x12
; CHECK-NEXT: mov x10, #8549
; CHECK-NEXT: movk x10, #22795, lsl #16
; CHECK-NEXT: movk x10, #17096, lsl #32
; CHECK-NEXT: fmov x11, d1
; CHECK-NEXT: movk x10, #45590, lsl #48
; CHECK-NEXT: smulh x10, x11, x10
; CHECK-NEXT: add x10, x10, x11
; CHECK-NEXT: asr x12, x10, #4
; CHECK-NEXT: add x10, x12, x10, lsr #63
; CHECK-NEXT: mov w12, #23
; CHECK-NEXT: msub x10, x10, x12, x11
; CHECK-NEXT: movi v0.2d, #0000000000000000
; CHECK-NEXT: fmov d1, x10
; CHECK-NEXT: mov v1.d[1], x8
; CHECK-NEXT: mov v0.d[1], x9
; CHECK-NEXT: ret
%1 = srem <4 x i64> %x, <i64 1, i64 654, i64 23, i64 5423>
ret <4 x i64> %1
}