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
9 ; CHECK-NEXT: mov w9, #47185
10 ; CHECK-NEXT: movk w8, #49807, lsl #16
11 ; CHECK-NEXT: movk w9, #1310, lsl #16
12 ; CHECK-NEXT: mov w10, #28834
13 ; CHECK-NEXT: movk w10, #2621, lsl #16
14 ; CHECK-NEXT: dup v1.4s, w8
15 ; CHECK-NEXT: dup v2.4s, w9
16 ; CHECK-NEXT: dup v3.4s, w10
17 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
18 ; CHECK-NEXT: cmhs v0.4s, v3.4s, v2.4s
19 ; CHECK-NEXT: movi v1.4s, #1
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
33 ; CHECK-NEXT: mov w9, #47184
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 w10, #23592
39 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
40 ; CHECK-NEXT: movk w10, #655, lsl #16
41 ; CHECK-NEXT: shl v0.4s, v2.4s, #30
42 ; CHECK-NEXT: ushr v1.4s, v2.4s, #2
43 ; CHECK-NEXT: dup v3.4s, w10
44 ; CHECK-NEXT: orr v0.16b, v1.16b, v0.16b
45 ; CHECK-NEXT: cmhs v0.4s, v3.4s, v0.4s
46 ; CHECK-NEXT: movi v1.4s, #1
47 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
49 %srem = srem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
50 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
51 %ret = zext <4 x i1> %cmp to <4 x i32>
55 ; Negative divisors should be negated, and thus this is still splat vectors.
58 define <4 x i32> @test_srem_odd_neg25(<4 x i32> %X) nounwind {
59 ; CHECK-LABEL: test_srem_odd_neg25:
61 ; CHECK-NEXT: mov w8, #23593
62 ; CHECK-NEXT: mov w9, #47185
63 ; CHECK-NEXT: movk w8, #49807, lsl #16
64 ; CHECK-NEXT: movk w9, #1310, lsl #16
65 ; CHECK-NEXT: mov w10, #28834
66 ; CHECK-NEXT: movk w10, #2621, lsl #16
67 ; CHECK-NEXT: dup v1.4s, w8
68 ; CHECK-NEXT: dup v2.4s, w9
69 ; CHECK-NEXT: dup v3.4s, w10
70 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
71 ; CHECK-NEXT: cmhs v0.4s, v3.4s, v2.4s
72 ; CHECK-NEXT: movi v1.4s, #1
73 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
75 %srem = srem <4 x i32> %X, <i32 25, i32 -25, i32 -25, i32 25>
76 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
77 %ret = zext <4 x i1> %cmp to <4 x i32>
82 define <4 x i32> @test_srem_even_neg100(<4 x i32> %X) nounwind {
83 ; CHECK-LABEL: test_srem_even_neg100:
85 ; CHECK-NEXT: mov w8, #23593
86 ; CHECK-NEXT: mov w9, #47184
87 ; CHECK-NEXT: movk w8, #49807, lsl #16
88 ; CHECK-NEXT: movk w9, #1310, lsl #16
89 ; CHECK-NEXT: dup v1.4s, w8
90 ; CHECK-NEXT: dup v2.4s, w9
91 ; CHECK-NEXT: mov w10, #23592
92 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
93 ; CHECK-NEXT: movk w10, #655, lsl #16
94 ; CHECK-NEXT: shl v0.4s, v2.4s, #30
95 ; CHECK-NEXT: ushr v1.4s, v2.4s, #2
96 ; CHECK-NEXT: dup v3.4s, w10
97 ; CHECK-NEXT: orr v0.16b, v1.16b, v0.16b
98 ; CHECK-NEXT: cmhs v0.4s, v3.4s, v0.4s
99 ; CHECK-NEXT: movi v1.4s, #1
100 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
102 %srem = srem <4 x i32> %X, <i32 -100, i32 100, i32 -100, i32 100>
103 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
104 %ret = zext <4 x i1> %cmp to <4 x i32>
108 ;------------------------------------------------------------------------------;
109 ; Comparison constant has undef elements.
110 ;------------------------------------------------------------------------------;
112 define <4 x i32> @test_srem_odd_undef1(<4 x i32> %X) nounwind {
113 ; CHECK-LABEL: test_srem_odd_undef1:
115 ; CHECK-NEXT: mov w8, #34079
116 ; CHECK-NEXT: movk w8, #20971, lsl #16
117 ; CHECK-NEXT: dup v2.4s, w8
118 ; CHECK-NEXT: smull2 v3.2d, v0.4s, v2.4s
119 ; CHECK-NEXT: smull v2.2d, v0.2s, v2.2s
120 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
121 ; CHECK-NEXT: sshr v3.4s, v2.4s, #3
122 ; CHECK-NEXT: movi v1.4s, #25
123 ; CHECK-NEXT: usra v3.4s, v2.4s, #31
124 ; CHECK-NEXT: mls v0.4s, v3.4s, v1.4s
125 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
126 ; CHECK-NEXT: movi v1.4s, #1
127 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
129 %srem = srem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
130 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 undef, i32 0>
131 %ret = zext <4 x i1> %cmp to <4 x i32>
135 define <4 x i32> @test_srem_even_undef1(<4 x i32> %X) nounwind {
136 ; CHECK-LABEL: test_srem_even_undef1:
138 ; CHECK-NEXT: mov w8, #34079
139 ; CHECK-NEXT: movk w8, #20971, lsl #16
140 ; CHECK-NEXT: dup v2.4s, w8
141 ; CHECK-NEXT: smull2 v3.2d, v0.4s, v2.4s
142 ; CHECK-NEXT: smull v2.2d, v0.2s, v2.2s
143 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
144 ; CHECK-NEXT: sshr v3.4s, v2.4s, #5
145 ; CHECK-NEXT: movi v1.4s, #100
146 ; CHECK-NEXT: usra v3.4s, v2.4s, #31
147 ; CHECK-NEXT: mls v0.4s, v3.4s, v1.4s
148 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
149 ; CHECK-NEXT: movi v1.4s, #1
150 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
152 %srem = srem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
153 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 undef, i32 0>
154 %ret = zext <4 x i1> %cmp to <4 x i32>
158 ;------------------------------------------------------------------------------;
160 ;------------------------------------------------------------------------------;
162 define <4 x i32> @test_srem_one_eq(<4 x i32> %X) nounwind {
163 ; CHECK-LABEL: test_srem_one_eq:
165 ; CHECK-NEXT: movi v0.4s, #1
167 %srem = srem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
168 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
169 %ret = zext <4 x i1> %cmp to <4 x i32>
172 define <4 x i32> @test_srem_one_ne(<4 x i32> %X) nounwind {
173 ; CHECK-LABEL: test_srem_one_ne:
175 ; CHECK-NEXT: movi v0.2d, #0000000000000000
177 %srem = srem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
178 %cmp = icmp ne <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
179 %ret = zext <4 x i1> %cmp to <4 x i32>
183 ; We can lower remainder of division by powers of two much better elsewhere.
184 define <4 x i32> @test_srem_pow2(<4 x i32> %X) nounwind {
185 ; CHECK-LABEL: test_srem_pow2:
187 ; CHECK-NEXT: sshr v1.4s, v0.4s, #31
188 ; CHECK-NEXT: mov v2.16b, v0.16b
189 ; CHECK-NEXT: usra v2.4s, v1.4s, #28
190 ; CHECK-NEXT: bic v2.4s, #15
191 ; CHECK-NEXT: sub v0.4s, v0.4s, v2.4s
192 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
193 ; CHECK-NEXT: movi v1.4s, #1
194 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
196 %srem = srem <4 x i32> %X, <i32 16, i32 16, i32 16, i32 16>
197 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
198 %ret = zext <4 x i1> %cmp to <4 x i32>
202 ; We could lower remainder of division by INT_MIN much better elsewhere.
203 define <4 x i32> @test_srem_int_min(<4 x i32> %X) nounwind {
204 ; CHECK-LABEL: test_srem_int_min:
206 ; CHECK-NEXT: sshr v1.4s, v0.4s, #31
207 ; CHECK-NEXT: mov v2.16b, v0.16b
208 ; CHECK-NEXT: movi v3.4s, #128, lsl #24
209 ; CHECK-NEXT: usra v2.4s, v1.4s, #1
210 ; CHECK-NEXT: and v1.16b, v2.16b, v3.16b
211 ; CHECK-NEXT: sub v0.4s, v0.4s, v1.4s
212 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
213 ; CHECK-NEXT: movi v1.4s, #1
214 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
216 %srem = srem <4 x i32> %X, <i32 2147483648, i32 2147483648, i32 2147483648, i32 2147483648>
217 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
218 %ret = zext <4 x i1> %cmp to <4 x i32>
222 ; We could lower remainder of division by all-ones much better elsewhere.
223 define <4 x i32> @test_srem_allones(<4 x i32> %X) nounwind {
224 ; CHECK-LABEL: test_srem_allones:
226 ; CHECK-NEXT: movi v0.4s, #1
228 %srem = srem <4 x i32> %X, <i32 4294967295, i32 4294967295, i32 4294967295, i32 4294967295>
229 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
230 %ret = zext <4 x i1> %cmp to <4 x i32>