1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
5 define <4 x i32> @test_srem_odd_25(<4 x i32> %X) nounwind {
6 ; CHECK-LABEL: test_srem_odd_25:
8 ; CHECK-NEXT: mov w8, #23593 // =0x5c29
9 ; CHECK-NEXT: mov w9, #47185 // =0xb851
10 ; CHECK-NEXT: movk w8, #49807, lsl #16
11 ; CHECK-NEXT: movk w9, #1310, lsl #16
12 ; CHECK-NEXT: dup v1.4s, w8
13 ; CHECK-NEXT: dup v2.4s, w9
14 ; CHECK-NEXT: mov w8, #28834 // =0x70a2
15 ; CHECK-NEXT: movk w8, #2621, lsl #16
16 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
17 ; CHECK-NEXT: dup v0.4s, w8
18 ; CHECK-NEXT: movi v1.4s, #1
19 ; CHECK-NEXT: cmhs v0.4s, v0.4s, v2.4s
20 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
22 %srem = srem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
23 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
24 %ret = zext <4 x i1> %cmp to <4 x i32>
29 define <4 x i32> @test_srem_even_100(<4 x i32> %X) nounwind {
30 ; CHECK-LABEL: test_srem_even_100:
32 ; CHECK-NEXT: mov w8, #23593 // =0x5c29
33 ; CHECK-NEXT: mov w9, #47184 // =0xb850
34 ; CHECK-NEXT: movk w8, #49807, lsl #16
35 ; CHECK-NEXT: movk w9, #1310, lsl #16
36 ; CHECK-NEXT: dup v1.4s, w8
37 ; CHECK-NEXT: dup v2.4s, w9
38 ; CHECK-NEXT: mov w8, #23592 // =0x5c28
39 ; CHECK-NEXT: movk w8, #655, lsl #16
40 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
41 ; CHECK-NEXT: dup v1.4s, w8
42 ; CHECK-NEXT: shl v0.4s, v2.4s, #30
43 ; CHECK-NEXT: usra v0.4s, v2.4s, #2
44 ; CHECK-NEXT: movi v2.4s, #1
45 ; CHECK-NEXT: cmhs v0.4s, v1.4s, v0.4s
46 ; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
48 %srem = srem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
49 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
50 %ret = zext <4 x i1> %cmp to <4 x i32>
54 ; Negative divisors should be negated, and thus this is still splat vectors.
57 define <4 x i32> @test_srem_odd_neg25(<4 x i32> %X) nounwind {
58 ; CHECK-LABEL: test_srem_odd_neg25:
60 ; CHECK-NEXT: mov w8, #23593 // =0x5c29
61 ; CHECK-NEXT: mov w9, #47185 // =0xb851
62 ; CHECK-NEXT: movk w8, #49807, lsl #16
63 ; CHECK-NEXT: movk w9, #1310, lsl #16
64 ; CHECK-NEXT: dup v1.4s, w8
65 ; CHECK-NEXT: dup v2.4s, w9
66 ; CHECK-NEXT: mov w8, #28834 // =0x70a2
67 ; CHECK-NEXT: movk w8, #2621, lsl #16
68 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
69 ; CHECK-NEXT: dup v0.4s, w8
70 ; CHECK-NEXT: movi v1.4s, #1
71 ; CHECK-NEXT: cmhs v0.4s, v0.4s, v2.4s
72 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
74 %srem = srem <4 x i32> %X, <i32 25, i32 -25, i32 -25, i32 25>
75 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
76 %ret = zext <4 x i1> %cmp to <4 x i32>
81 define <4 x i32> @test_srem_even_neg100(<4 x i32> %X) nounwind {
82 ; CHECK-LABEL: test_srem_even_neg100:
84 ; CHECK-NEXT: mov w8, #23593 // =0x5c29
85 ; CHECK-NEXT: mov w9, #47184 // =0xb850
86 ; CHECK-NEXT: movk w8, #49807, lsl #16
87 ; CHECK-NEXT: movk w9, #1310, lsl #16
88 ; CHECK-NEXT: dup v1.4s, w8
89 ; CHECK-NEXT: dup v2.4s, w9
90 ; CHECK-NEXT: mov w8, #23592 // =0x5c28
91 ; CHECK-NEXT: movk w8, #655, lsl #16
92 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
93 ; CHECK-NEXT: dup v1.4s, w8
94 ; CHECK-NEXT: shl v0.4s, v2.4s, #30
95 ; CHECK-NEXT: usra v0.4s, v2.4s, #2
96 ; CHECK-NEXT: movi v2.4s, #1
97 ; CHECK-NEXT: cmhs v0.4s, v1.4s, v0.4s
98 ; CHECK-NEXT: and v0.16b, v0.16b, v2.16b
100 %srem = srem <4 x i32> %X, <i32 -100, i32 100, i32 -100, i32 100>
101 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
102 %ret = zext <4 x i1> %cmp to <4 x i32>
106 ;------------------------------------------------------------------------------;
107 ; Comparison constant has undef elements.
108 ;------------------------------------------------------------------------------;
110 define <4 x i32> @test_srem_odd_undef1(<4 x i32> %X) nounwind {
111 ; CHECK-LABEL: test_srem_odd_undef1:
113 ; CHECK-NEXT: mov w8, #34079 // =0x851f
114 ; CHECK-NEXT: movk w8, #20971, lsl #16
115 ; CHECK-NEXT: dup v1.4s, w8
116 ; CHECK-NEXT: smull2 v2.2d, v0.4s, v1.4s
117 ; CHECK-NEXT: smull v1.2d, v0.2s, v1.2s
118 ; CHECK-NEXT: uzp2 v1.4s, v1.4s, v2.4s
119 ; CHECK-NEXT: sshr v2.4s, v1.4s, #3
120 ; CHECK-NEXT: usra v2.4s, v1.4s, #31
121 ; CHECK-NEXT: movi v1.4s, #25
122 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
123 ; CHECK-NEXT: movi v1.4s, #1
124 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
125 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
127 %srem = srem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
128 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 undef, i32 0>
129 %ret = zext <4 x i1> %cmp to <4 x i32>
133 define <4 x i32> @test_srem_even_undef1(<4 x i32> %X) nounwind {
134 ; CHECK-LABEL: test_srem_even_undef1:
136 ; CHECK-NEXT: mov w8, #34079 // =0x851f
137 ; CHECK-NEXT: movk w8, #20971, lsl #16
138 ; CHECK-NEXT: dup v1.4s, w8
139 ; CHECK-NEXT: smull2 v2.2d, v0.4s, v1.4s
140 ; CHECK-NEXT: smull v1.2d, v0.2s, v1.2s
141 ; CHECK-NEXT: uzp2 v1.4s, v1.4s, v2.4s
142 ; CHECK-NEXT: sshr v2.4s, v1.4s, #5
143 ; CHECK-NEXT: usra v2.4s, v1.4s, #31
144 ; CHECK-NEXT: movi v1.4s, #100
145 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
146 ; CHECK-NEXT: movi v1.4s, #1
147 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
148 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
150 %srem = srem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
151 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 undef, i32 0>
152 %ret = zext <4 x i1> %cmp to <4 x i32>
156 ;------------------------------------------------------------------------------;
158 ;------------------------------------------------------------------------------;
160 define <4 x i32> @test_srem_one_eq(<4 x i32> %X) nounwind {
161 ; CHECK-LABEL: test_srem_one_eq:
163 ; CHECK-NEXT: movi v0.4s, #1
165 %srem = srem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
166 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
167 %ret = zext <4 x i1> %cmp to <4 x i32>
170 define <4 x i32> @test_srem_one_ne(<4 x i32> %X) nounwind {
171 ; CHECK-LABEL: test_srem_one_ne:
173 ; CHECK-NEXT: movi v0.2d, #0000000000000000
175 %srem = srem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
176 %cmp = icmp ne <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
177 %ret = zext <4 x i1> %cmp to <4 x i32>
181 ; We can lower remainder of division by powers of two much better elsewhere.
182 define <4 x i32> @test_srem_pow2(<4 x i32> %X) nounwind {
183 ; CHECK-LABEL: test_srem_pow2:
185 ; CHECK-NEXT: cmlt v1.4s, v0.4s, #0
186 ; CHECK-NEXT: mov v2.16b, v0.16b
187 ; CHECK-NEXT: usra v2.4s, v1.4s, #28
188 ; CHECK-NEXT: movi v1.4s, #1
189 ; CHECK-NEXT: bic v2.4s, #15
190 ; CHECK-NEXT: sub v0.4s, v0.4s, v2.4s
191 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
192 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
194 %srem = srem <4 x i32> %X, <i32 16, i32 16, i32 16, i32 16>
195 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
196 %ret = zext <4 x i1> %cmp to <4 x i32>
200 ; We could lower remainder of division by INT_MIN much better elsewhere.
201 define <4 x i32> @test_srem_int_min(<4 x i32> %X) nounwind {
202 ; CHECK-LABEL: test_srem_int_min:
204 ; CHECK-NEXT: cmlt v1.4s, v0.4s, #0
205 ; CHECK-NEXT: mov v2.16b, v0.16b
206 ; CHECK-NEXT: usra v2.4s, v1.4s, #1
207 ; CHECK-NEXT: movi v1.4s, #128, lsl #24
208 ; CHECK-NEXT: and v1.16b, v2.16b, v1.16b
209 ; CHECK-NEXT: add v0.4s, v1.4s, v0.4s
210 ; CHECK-NEXT: movi v1.4s, #1
211 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
212 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
214 %srem = srem <4 x i32> %X, <i32 2147483648, i32 2147483648, i32 2147483648, i32 2147483648>
215 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
216 %ret = zext <4 x i1> %cmp to <4 x i32>
220 ; We could lower remainder of division by all-ones much better elsewhere.
221 define <4 x i32> @test_srem_allones(<4 x i32> %X) nounwind {
222 ; CHECK-LABEL: test_srem_allones:
224 ; CHECK-NEXT: movi v0.4s, #1
226 %srem = srem <4 x i32> %X, <i32 4294967295, i32 4294967295, i32 4294967295, i32 4294967295>
227 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
228 %ret = zext <4 x i1> %cmp to <4 x i32>