1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
6 define i32 @zext_ifpos(i32 %x) {
7 ; CHECK-LABEL: zext_ifpos:
9 ; CHECK-NEXT: mvn w8, w0
10 ; CHECK-NEXT: lsr w0, w8, #31
12 %c = icmp sgt i32 %x, -1
13 %e = zext i1 %c to i32
17 define i32 @add_zext_ifpos(i32 %x) {
18 ; CHECK-LABEL: add_zext_ifpos:
20 ; CHECK-NEXT: asr w8, w0, #31
21 ; CHECK-NEXT: add w0, w8, #42 // =42
23 %c = icmp sgt i32 %x, -1
24 %e = zext i1 %c to i32
29 define <4 x i32> @add_zext_ifpos_vec_splat(<4 x i32> %x) {
30 ; CHECK-LABEL: add_zext_ifpos_vec_splat:
32 ; CHECK-NEXT: movi v1.2d, #0xffffffffffffffff
33 ; CHECK-NEXT: cmgt v0.4s, v0.4s, v1.4s
34 ; CHECK-NEXT: movi v1.4s, #41
35 ; CHECK-NEXT: sub v0.4s, v1.4s, v0.4s
37 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
38 %e = zext <4 x i1> %c to <4 x i32>
39 %r = add <4 x i32> %e, <i32 41, i32 41, i32 41, i32 41>
43 define i32 @sel_ifpos_tval_bigger(i32 %x) {
44 ; CHECK-LABEL: sel_ifpos_tval_bigger:
46 ; CHECK-NEXT: cmp w0, #0 // =0
47 ; CHECK-NEXT: mov w8, #41
48 ; CHECK-NEXT: cinc w0, w8, ge
50 %c = icmp sgt i32 %x, -1
51 %r = select i1 %c, i32 42, i32 41
55 define i32 @sext_ifpos(i32 %x) {
56 ; CHECK-LABEL: sext_ifpos:
58 ; CHECK-NEXT: mvn w8, w0
59 ; CHECK-NEXT: asr w0, w8, #31
61 %c = icmp sgt i32 %x, -1
62 %e = sext i1 %c to i32
66 define i32 @add_sext_ifpos(i32 %x) {
67 ; CHECK-LABEL: add_sext_ifpos:
69 ; CHECK-NEXT: lsr w8, w0, #31
70 ; CHECK-NEXT: add w0, w8, #41 // =41
72 %c = icmp sgt i32 %x, -1
73 %e = sext i1 %c to i32
78 define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) {
79 ; CHECK-LABEL: add_sext_ifpos_vec_splat:
81 ; CHECK-NEXT: movi v1.2d, #0xffffffffffffffff
82 ; CHECK-NEXT: cmgt v0.4s, v0.4s, v1.4s
83 ; CHECK-NEXT: movi v1.4s, #42
84 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
86 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
87 %e = sext <4 x i1> %c to <4 x i32>
88 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
92 define i32 @sel_ifpos_fval_bigger(i32 %x) {
93 ; CHECK-LABEL: sel_ifpos_fval_bigger:
95 ; CHECK-NEXT: cmp w0, #0 // =0
96 ; CHECK-NEXT: mov w8, #41
97 ; CHECK-NEXT: cinc w0, w8, lt
99 %c = icmp sgt i32 %x, -1
100 %r = select i1 %c, i32 41, i32 42
106 define i32 @zext_ifneg(i32 %x) {
107 ; CHECK-LABEL: zext_ifneg:
109 ; CHECK-NEXT: lsr w0, w0, #31
111 %c = icmp slt i32 %x, 0
112 %r = zext i1 %c to i32
116 define i32 @add_zext_ifneg(i32 %x) {
117 ; CHECK-LABEL: add_zext_ifneg:
119 ; CHECK-NEXT: lsr w8, w0, #31
120 ; CHECK-NEXT: add w0, w8, #41 // =41
122 %c = icmp slt i32 %x, 0
123 %e = zext i1 %c to i32
128 define i32 @sel_ifneg_tval_bigger(i32 %x) {
129 ; CHECK-LABEL: sel_ifneg_tval_bigger:
131 ; CHECK-NEXT: cmp w0, #0 // =0
132 ; CHECK-NEXT: mov w8, #41
133 ; CHECK-NEXT: cinc w0, w8, lt
135 %c = icmp slt i32 %x, 0
136 %r = select i1 %c, i32 42, i32 41
140 define i32 @sext_ifneg(i32 %x) {
141 ; CHECK-LABEL: sext_ifneg:
143 ; CHECK-NEXT: asr w0, w0, #31
145 %c = icmp slt i32 %x, 0
146 %r = sext i1 %c to i32
150 define i32 @add_sext_ifneg(i32 %x) {
151 ; CHECK-LABEL: add_sext_ifneg:
153 ; CHECK-NEXT: asr w8, w0, #31
154 ; CHECK-NEXT: add w0, w8, #42 // =42
156 %c = icmp slt i32 %x, 0
157 %e = sext i1 %c to i32
162 define i32 @sel_ifneg_fval_bigger(i32 %x) {
163 ; CHECK-LABEL: sel_ifneg_fval_bigger:
165 ; CHECK-NEXT: cmp w0, #0 // =0
166 ; CHECK-NEXT: mov w8, #41
167 ; CHECK-NEXT: cinc w0, w8, ge
169 %c = icmp slt i32 %x, 0
170 %r = select i1 %c, i32 41, i32 42
174 define i32 @add_lshr_not(i32 %x) {
175 ; CHECK-LABEL: add_lshr_not:
177 ; CHECK-NEXT: asr w8, w0, #31
178 ; CHECK-NEXT: add w0, w8, #42 // =42
180 %not = xor i32 %x, -1
181 %sh = lshr i32 %not, 31
186 define <4 x i32> @add_lshr_not_vec_splat(<4 x i32> %x) {
187 ; CHECK-LABEL: add_lshr_not_vec_splat:
189 ; CHECK-NEXT: movi v1.4s, #43
190 ; CHECK-NEXT: ssra v1.4s, v0.4s, #31
191 ; CHECK-NEXT: mov v0.16b, v1.16b
193 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
194 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
195 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
199 define i32 @sub_lshr_not(i32 %x) {
200 ; CHECK-LABEL: sub_lshr_not:
202 ; CHECK-NEXT: mov w8, #42
203 ; CHECK-NEXT: bfxil w8, w0, #31, #1
204 ; CHECK-NEXT: mov w0, w8
206 %not = xor i32 %x, -1
207 %sh = lshr i32 %not, 31
212 define <4 x i32> @sub_lshr_not_vec_splat(<4 x i32> %x) {
213 ; CHECK-LABEL: sub_lshr_not_vec_splat:
215 ; CHECK-NEXT: movi v1.4s, #41
216 ; CHECK-NEXT: usra v1.4s, v0.4s, #31
217 ; CHECK-NEXT: mov v0.16b, v1.16b
219 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
220 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
221 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %e
225 define i32 @sub_lshr(i32 %x, i32 %y) {
226 ; CHECK-LABEL: sub_lshr:
228 ; CHECK-NEXT: add w0, w1, w0, asr #31
230 %sh = lshr i32 %x, 31
235 define <4 x i32> @sub_lshr_vec(<4 x i32> %x, <4 x i32> %y) {
236 ; CHECK-LABEL: sub_lshr_vec:
238 ; CHECK-NEXT: ssra v1.4s, v0.4s, #31
239 ; CHECK-NEXT: mov v0.16b, v1.16b
241 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
242 %r = sub <4 x i32> %y, %sh
246 define i32 @sub_const_op_lshr(i32 %x) {
247 ; CHECK-LABEL: sub_const_op_lshr:
249 ; CHECK-NEXT: asr w8, w0, #31
250 ; CHECK-NEXT: add w0, w8, #43 // =43
252 %sh = lshr i32 %x, 31
257 define <4 x i32> @sub_const_op_lshr_vec(<4 x i32> %x) {
258 ; CHECK-LABEL: sub_const_op_lshr_vec:
260 ; CHECK-NEXT: movi v1.4s, #42
261 ; CHECK-NEXT: ssra v1.4s, v0.4s, #31
262 ; CHECK-NEXT: mov v0.16b, v1.16b
264 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
265 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %sh