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, #34079
30 ; CHECK-NEXT: movk w8, #20971, lsl #16
31 ; CHECK-NEXT: dup v2.4s, w8
32 ; CHECK-NEXT: umull2 v3.2d, v0.4s, v2.4s
33 ; CHECK-NEXT: umull v2.2d, v0.2s, v2.2s
34 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
35 ; CHECK-NEXT: movi v1.4s, #100
36 ; CHECK-NEXT: ushr v2.4s, v2.4s, #5
37 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
38 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
39 ; CHECK-NEXT: movi v1.4s, #1
40 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
42 %urem = urem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
43 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
44 %ret = zext <4 x i1> %cmp to <4 x i32>
48 ;------------------------------------------------------------------------------;
49 ; Comparison constant has undef elements.
50 ;------------------------------------------------------------------------------;
52 define <4 x i32> @test_urem_odd_undef1(<4 x i32> %X) nounwind {
53 ; CHECK-LABEL: test_urem_odd_undef1:
55 ; CHECK-NEXT: mov w8, #34079
56 ; CHECK-NEXT: movk w8, #20971, lsl #16
57 ; CHECK-NEXT: dup v2.4s, w8
58 ; CHECK-NEXT: umull2 v3.2d, v0.4s, v2.4s
59 ; CHECK-NEXT: umull v2.2d, v0.2s, v2.2s
60 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
61 ; CHECK-NEXT: movi v1.4s, #25
62 ; CHECK-NEXT: ushr v2.4s, v2.4s, #3
63 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
64 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
65 ; CHECK-NEXT: movi v1.4s, #1
66 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
68 %urem = urem <4 x i32> %X, <i32 25, i32 25, i32 25, i32 25>
69 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 undef, i32 0>
70 %ret = zext <4 x i1> %cmp to <4 x i32>
74 define <4 x i32> @test_urem_even_undef1(<4 x i32> %X) nounwind {
75 ; CHECK-LABEL: test_urem_even_undef1:
77 ; CHECK-NEXT: mov w8, #34079
78 ; CHECK-NEXT: movk w8, #20971, lsl #16
79 ; CHECK-NEXT: dup v2.4s, w8
80 ; CHECK-NEXT: umull2 v3.2d, v0.4s, v2.4s
81 ; CHECK-NEXT: umull v2.2d, v0.2s, v2.2s
82 ; CHECK-NEXT: uzp2 v2.4s, v2.4s, v3.4s
83 ; CHECK-NEXT: movi v1.4s, #100
84 ; CHECK-NEXT: ushr v2.4s, v2.4s, #5
85 ; CHECK-NEXT: mls v0.4s, v2.4s, v1.4s
86 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
87 ; CHECK-NEXT: movi v1.4s, #1
88 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
90 %urem = urem <4 x i32> %X, <i32 100, i32 100, i32 100, i32 100>
91 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 undef, i32 0>
92 %ret = zext <4 x i1> %cmp to <4 x i32>
96 ;------------------------------------------------------------------------------;
98 ;------------------------------------------------------------------------------;
100 ; We can lower remainder of division by powers of two much better elsewhere.
101 define <4 x i32> @test_urem_pow2(<4 x i32> %X) nounwind {
102 ; CHECK-LABEL: test_urem_pow2:
104 ; CHECK-NEXT: movi v1.4s, #15
105 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
106 ; CHECK-NEXT: cmeq v0.4s, v0.4s, #0
107 ; CHECK-NEXT: movi v1.4s, #1
108 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
110 %urem = urem <4 x i32> %X, <i32 16, i32 16, i32 16, i32 16>
111 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
112 %ret = zext <4 x i1> %cmp to <4 x i32>
116 ; We could lower remainder of division by all-ones much better elsewhere.
117 define <4 x i32> @test_urem_allones(<4 x i32> %X) nounwind {
118 ; CHECK-LABEL: test_urem_allones:
120 ; CHECK-NEXT: neg v0.4s, v0.4s
121 ; CHECK-NEXT: movi v1.4s, #1
122 ; CHECK-NEXT: cmhs v0.4s, v1.4s, v0.4s
123 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
125 %urem = urem <4 x i32> %X, <i32 4294967295, i32 4294967295, i32 4294967295, i32 4294967295>
126 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
127 %ret = zext <4 x i1> %cmp to <4 x i32>
131 ; If all divisors are ones, this is constant-folded.
132 define <4 x i32> @test_urem_one_eq(<4 x i32> %X) nounwind {
133 ; CHECK-LABEL: test_urem_one_eq:
135 ; CHECK-NEXT: movi v0.4s, #1
137 %urem = urem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
138 %cmp = icmp eq <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
139 %ret = zext <4 x i1> %cmp to <4 x i32>
142 define <4 x i32> @test_urem_one_ne(<4 x i32> %X) nounwind {
143 ; CHECK-LABEL: test_urem_one_ne:
145 ; CHECK-NEXT: movi v0.2d, #0000000000000000
147 %urem = urem <4 x i32> %X, <i32 1, i32 1, i32 1, i32 1>
148 %cmp = icmp ne <4 x i32> %urem, <i32 0, i32 0, i32 0, i32 0>
149 %ret = zext <4 x i1> %cmp to <4 x i32>