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_urem_odd_25(<4 x i32> %X) nounwind {
6 ; CHECK-LABEL: test_urem_odd_25:
8 ; CHECK-NEXT: mov w8, #23593
9 ; CHECK-NEXT: movk w8, #49807, lsl #16
10 ; CHECK-NEXT: mov w9, #28835
11 ; CHECK-NEXT: movk w9, #2621, lsl #16
12 ; CHECK-NEXT: dup v1.4s, w8
13 ; CHECK-NEXT: dup v2.4s, w9
14 ; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
15 ; CHECK-NEXT: cmhs v0.4s, v2.4s, v0.4s
16 ; CHECK-NEXT: movi v1.4s, #1
17 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
19 %urem = urem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
20 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
21 %ret = zext <4 x i1> %cmp to <4 x i32>
26 define <4 x i32> @test_urem_even_100(<4 x i32> %X) nounwind {
27 ; CHECK-LABEL: test_urem_even_100:
29 ; CHECK-NEXT: mov w8, #23593
30 ; CHECK-NEXT: movk w8, #49807, lsl #16
31 ; CHECK-NEXT: dup v1.4s, w8
32 ; CHECK-NEXT: mov w9, #23592
33 ; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
34 ; CHECK-NEXT: movk w9, #655, lsl #16
35 ; CHECK-NEXT: shl v1.4s, v0.4s, #30
36 ; CHECK-NEXT: ushr v0.4s, v0.4s, #2
37 ; CHECK-NEXT: dup v2.4s, w9
38 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
39 ; CHECK-NEXT: cmhs v0.4s, v2.4s, v0.4s
40 ; CHECK-NEXT: movi v1.4s, #1
41 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
43 %urem = urem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
44 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
45 %ret = zext <4 x i1> %cmp to <4 x i32>
49 ; Negative divisors should be negated, and thus this is still splat vectors.
52 define <4 x i32> @test_urem_odd_neg25(<4 x i32> %X) nounwind {
53 ; CHECK-LABEL: test_urem_odd_neg25:
55 ; CHECK-NEXT: adrp x8, .LCPI2_0
56 ; CHECK-NEXT: adrp x9, .LCPI2_1
57 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI2_0]
58 ; CHECK-NEXT: ldr q2, [x9, :lo12:.LCPI2_1]
59 ; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
60 ; CHECK-NEXT: cmhs v0.4s, v2.4s, v0.4s
61 ; CHECK-NEXT: movi v1.4s, #1
62 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
64 %urem = urem <4 x i32> %X, <i32 25, i32 -25, i32 -25, i32 25>
65 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
66 %ret = zext <4 x i1> %cmp to <4 x i32>
71 define <4 x i32> @test_urem_even_neg100(<4 x i32> %X) nounwind {
72 ; CHECK-LABEL: test_urem_even_neg100:
74 ; CHECK-NEXT: adrp x8, .LCPI3_0
75 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI3_0]
76 ; CHECK-NEXT: adrp x8, .LCPI3_1
77 ; CHECK-NEXT: ldr q2, [x8, :lo12:.LCPI3_1]
78 ; CHECK-NEXT: mul v0.4s, v0.4s, v1.4s
79 ; CHECK-NEXT: shl v1.4s, v0.4s, #30
80 ; CHECK-NEXT: ushr v0.4s, v0.4s, #2
81 ; CHECK-NEXT: orr v0.16b, v0.16b, v1.16b
82 ; CHECK-NEXT: cmhs v0.4s, v2.4s, v0.4s
83 ; CHECK-NEXT: movi v1.4s, #1
84 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
86 %urem = urem <4 x i32> %X, <i32 -100, i32 100, i32 -100, i32 100>
87 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
88 %ret = zext <4 x i1> %cmp to <4 x i32>
92 ;------------------------------------------------------------------------------;
93 ; Comparison constant has undef elements.
94 ;------------------------------------------------------------------------------;
96 define <4 x i32> @test_urem_odd_undef1(<4 x i32> %X) nounwind {
97 ; CHECK-LABEL: test_urem_odd_undef1:
99 ; CHECK-NEXT: mov w8, #34079
100 ; CHECK-NEXT: movk w8, #20971, lsl #16
101 ; CHECK-NEXT: dup v2.4s, w8
102 ; CHECK-NEXT: umull2 v3.2d, v0.4s, v2.4s
103 ; CHECK-NEXT: umull v2.2d, v0.2s, v2.2s
104 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
105 ; CHECK-NEXT: movi v1.4s, #25
106 ; CHECK-NEXT: ushr v2.4s, v2.4s, #3
107 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
108 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
109 ; CHECK-NEXT: movi v1.4s, #1
110 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
112 %urem = urem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
113 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 undef, i32 0>
114 %ret = zext <4 x i1> %cmp to <4 x i32>
118 define <4 x i32> @test_urem_even_undef1(<4 x i32> %X) nounwind {
119 ; CHECK-LABEL: test_urem_even_undef1:
121 ; CHECK-NEXT: mov w8, #34079
122 ; CHECK-NEXT: movk w8, #20971, lsl #16
123 ; CHECK-NEXT: dup v2.4s, w8
124 ; CHECK-NEXT: umull2 v3.2d, v0.4s, v2.4s
125 ; CHECK-NEXT: umull v2.2d, v0.2s, v2.2s
126 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
127 ; CHECK-NEXT: movi v1.4s, #100
128 ; CHECK-NEXT: ushr v2.4s, v2.4s, #5
129 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
130 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
131 ; CHECK-NEXT: movi v1.4s, #1
132 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
134 %urem = urem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
135 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 undef, i32 0>
136 %ret = zext <4 x i1> %cmp to <4 x i32>
140 ;------------------------------------------------------------------------------;
142 ;------------------------------------------------------------------------------;
144 define <4 x i32> @test_urem_one_eq(<4 x i32> %X) nounwind {
145 ; CHECK-LABEL: test_urem_one_eq:
147 ; CHECK-NEXT: movi v0.4s, #1
149 %urem = urem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
150 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
151 %ret = zext <4 x i1> %cmp to <4 x i32>
154 define <4 x i32> @test_urem_one_ne(<4 x i32> %X) nounwind {
155 ; CHECK-LABEL: test_urem_one_ne:
157 ; CHECK-NEXT: movi v0.2d, #0000000000000000
159 %urem = urem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
160 %cmp = icmp ne <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
161 %ret = zext <4 x i1> %cmp to <4 x i32>
165 ; We can lower remainder of division by powers of two much better elsewhere.
166 define <4 x i32> @test_urem_pow2(<4 x i32> %X) nounwind {
167 ; CHECK-LABEL: test_urem_pow2:
169 ; CHECK-NEXT: movi v1.4s, #15
170 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
171 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
172 ; CHECK-NEXT: movi v1.4s, #1
173 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
175 %urem = urem <4 x i32> %X, <i32 16, i32 16, i32 16, i32 16>
176 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
177 %ret = zext <4 x i1> %cmp to <4 x i32>
181 ; We could lower remainder of division by INT_MIN much better elsewhere.
182 define <4 x i32> @test_urem_int_min(<4 x i32> %X) nounwind {
183 ; CHECK-LABEL: test_urem_int_min:
185 ; CHECK-NEXT: bic v0.4s, #128, lsl #24
186 ; CHECK-NEXT: movi v1.4s, #1
187 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
188 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
190 %urem = urem <4 x i32> %X, <i32 2147483648, i32 2147483648, i32 2147483648, i32 2147483648>
191 %cmp = icmp eq <4 x i32> %urem, <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 all-ones much better elsewhere.
197 define <4 x i32> @test_urem_allones(<4 x i32> %X) nounwind {
198 ; CHECK-LABEL: test_urem_allones:
200 ; CHECK-NEXT: neg v0.4s, v0.4s
201 ; CHECK-NEXT: movi v1.4s, #1
202 ; CHECK-NEXT: cmhs v0.4s, v1.4s, v0.4s
203 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
205 %urem = urem <4 x i32> %X, <i32 4294967295, i32 4294967295, i32 4294967295, i32 4294967295>
206 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
207 %ret = zext <4 x i1> %cmp to <4 x i32>