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, #34079
33 ; CHECK-NEXT: movk w8, #20971, lsl #16
34 ; CHECK-NEXT: dup v2.4s, w8
35 ; CHECK-NEXT: smull2 v3.2d, v0.4s, v2.4s
36 ; CHECK-NEXT: smull v2.2d, v0.2s, v2.2s
37 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
38 ; CHECK-NEXT: sshr v3.4s, v2.4s, #5
39 ; CHECK-NEXT: movi v1.4s, #100
40 ; CHECK-NEXT: usra v3.4s, v2.4s, #31
41 ; CHECK-NEXT: mls v0.4s, v3.4s, v1.4s
42 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
43 ; CHECK-NEXT: movi v1.4s, #1
44 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
46 %srem = srem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
47 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
48 %ret = zext <4 x i1> %cmp to <4 x i32>
52 ; Negative divisors should be negated, and thus this is still splat vectors.
55 define <4 x i32> @test_srem_odd_neg25(<4 x i32> %X) nounwind {
56 ; CHECK-LABEL: test_srem_odd_neg25:
58 ; CHECK-NEXT: mov w8, #23593
59 ; CHECK-NEXT: mov w9, #47185
60 ; CHECK-NEXT: movk w8, #49807, lsl #16
61 ; CHECK-NEXT: movk w9, #1310, lsl #16
62 ; CHECK-NEXT: mov w10, #28834
63 ; CHECK-NEXT: movk w10, #2621, lsl #16
64 ; CHECK-NEXT: dup v1.4s, w8
65 ; CHECK-NEXT: dup v2.4s, w9
66 ; CHECK-NEXT: dup v3.4s, w10
67 ; CHECK-NEXT: mla v2.4s, v0.4s, v1.4s
68 ; CHECK-NEXT: cmhs v0.4s, v3.4s, v2.4s
69 ; CHECK-NEXT: movi v1.4s, #1
70 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
72 %srem = srem <4 x i32> %X, <i32 25, i32 -25, i32 -25, i32 25>
73 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
74 %ret = zext <4 x i1> %cmp to <4 x i32>
79 define <4 x i32> @test_srem_even_neg100(<4 x i32> %X) nounwind {
80 ; CHECK-LABEL: test_srem_even_neg100:
82 ; CHECK-NEXT: adrp x8, .LCPI3_0
83 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI3_0]
84 ; CHECK-NEXT: adrp x8, .LCPI3_1
85 ; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI3_1]
86 ; CHECK-NEXT: smull2 v3.2d, v0.4s, v1.4s
87 ; CHECK-NEXT: smull v1.2d, v0.2s, v1.2s
88 ; CHECK-NEXT: uzp2 v1.4s, v1.4s, v3.4s
89 ; CHECK-NEXT: sshr v3.4s, v1.4s, #5
90 ; CHECK-NEXT: usra v3.4s, v1.4s, #31
91 ; CHECK-NEXT: mls v0.4s, v3.4s, v2.4s
92 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
93 ; CHECK-NEXT: movi v1.4s, #1
94 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
96 %srem = srem <4 x i32> %X, <i32 -100, i32 100, i32 -100, i32 100>
97 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
98 %ret = zext <4 x i1> %cmp to <4 x i32>
102 ;------------------------------------------------------------------------------;
103 ; Comparison constant has undef elements.
104 ;------------------------------------------------------------------------------;
106 define <4 x i32> @test_srem_odd_undef1(<4 x i32> %X) nounwind {
107 ; CHECK-LABEL: test_srem_odd_undef1:
109 ; CHECK-NEXT: mov w8, #34079
110 ; CHECK-NEXT: movk w8, #20971, lsl #16
111 ; CHECK-NEXT: dup v2.4s, w8
112 ; CHECK-NEXT: smull2 v3.2d, v0.4s, v2.4s
113 ; CHECK-NEXT: smull v2.2d, v0.2s, v2.2s
114 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
115 ; CHECK-NEXT: sshr v3.4s, v2.4s, #3
116 ; CHECK-NEXT: movi v1.4s, #25
117 ; CHECK-NEXT: usra v3.4s, v2.4s, #31
118 ; CHECK-NEXT: mls v0.4s, v3.4s, v1.4s
119 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
120 ; CHECK-NEXT: movi v1.4s, #1
121 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
123 %srem = srem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
124 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 undef, i32 0>
125 %ret = zext <4 x i1> %cmp to <4 x i32>
129 define <4 x i32> @test_srem_even_undef1(<4 x i32> %X) nounwind {
130 ; CHECK-LABEL: test_srem_even_undef1:
132 ; CHECK-NEXT: mov w8, #34079
133 ; CHECK-NEXT: movk w8, #20971, lsl #16
134 ; CHECK-NEXT: dup v2.4s, w8
135 ; CHECK-NEXT: smull2 v3.2d, v0.4s, v2.4s
136 ; CHECK-NEXT: smull v2.2d, v0.2s, v2.2s
137 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
138 ; CHECK-NEXT: sshr v3.4s, v2.4s, #5
139 ; CHECK-NEXT: movi v1.4s, #100
140 ; CHECK-NEXT: usra v3.4s, v2.4s, #31
141 ; CHECK-NEXT: mls v0.4s, v3.4s, v1.4s
142 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
143 ; CHECK-NEXT: movi v1.4s, #1
144 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
146 %srem = srem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
147 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 undef, i32 0>
148 %ret = zext <4 x i1> %cmp to <4 x i32>
152 ;------------------------------------------------------------------------------;
154 ;------------------------------------------------------------------------------;
156 define <4 x i32> @test_srem_one_eq(<4 x i32> %X) nounwind {
157 ; CHECK-LABEL: test_srem_one_eq:
159 ; CHECK-NEXT: movi v0.4s, #1
161 %srem = srem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
162 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
163 %ret = zext <4 x i1> %cmp to <4 x i32>
166 define <4 x i32> @test_srem_one_ne(<4 x i32> %X) nounwind {
167 ; CHECK-LABEL: test_srem_one_ne:
169 ; CHECK-NEXT: movi v0.2d, #0000000000000000
171 %srem = srem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
172 %cmp = icmp ne <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
173 %ret = zext <4 x i1> %cmp to <4 x i32>
177 ; We can lower remainder of division by powers of two much better elsewhere.
178 define <4 x i32> @test_srem_pow2(<4 x i32> %X) nounwind {
179 ; CHECK-LABEL: test_srem_pow2:
181 ; CHECK-NEXT: sshr v1.4s, v0.4s, #31
182 ; CHECK-NEXT: mov v2.16b, v0.16b
183 ; CHECK-NEXT: usra v2.4s, v1.4s, #28
184 ; CHECK-NEXT: bic v2.4s, #15
185 ; CHECK-NEXT: sub v0.4s, v0.4s, v2.4s
186 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
187 ; CHECK-NEXT: movi v1.4s, #1
188 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
190 %srem = srem <4 x i32> %X, <i32 16, i32 16, i32 16, i32 16>
191 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
192 %ret = zext <4 x i1> %cmp to <4 x i32>
196 ; We could lower remainder of division by INT_MIN much better elsewhere.
197 define <4 x i32> @test_srem_int_min(<4 x i32> %X) nounwind {
198 ; CHECK-LABEL: test_srem_int_min:
200 ; CHECK-NEXT: sshr v1.4s, v0.4s, #31
201 ; CHECK-NEXT: mov v2.16b, v0.16b
202 ; CHECK-NEXT: movi v3.4s, #128, lsl #24
203 ; CHECK-NEXT: usra v2.4s, v1.4s, #1
204 ; CHECK-NEXT: and v1.16b, v2.16b, v3.16b
205 ; CHECK-NEXT: sub v0.4s, v0.4s, v1.4s
206 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
207 ; CHECK-NEXT: movi v1.4s, #1
208 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
210 %srem = srem <4 x i32> %X, <i32 2147483648, i32 2147483648, i32 2147483648, i32 2147483648>
211 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
212 %ret = zext <4 x i1> %cmp to <4 x i32>
216 ; We could lower remainder of division by all-ones much better elsewhere.
217 define <4 x i32> @test_srem_allones(<4 x i32> %X) nounwind {
218 ; CHECK-LABEL: test_srem_allones:
220 ; CHECK-NEXT: movi v0.4s, #1
222 %srem = srem <4 x i32> %X, <i32 4294967295, i32 4294967295, i32 4294967295, i32 4294967295>
223 %cmp = icmp eq <4 x i32> %srem, <i32 0, i32 0, i32 0, i32 0>
224 %ret = zext <4 x i1> %cmp to <4 x i32>