1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s
6 define i32 @zext_ifpos(i32 %x) {
7 ; CHECK-LABEL: zext_ifpos:
9 ; CHECK-NEXT: movl %edi, %eax
10 ; CHECK-NEXT: notl %eax
11 ; CHECK-NEXT: shrl $31, %eax
13 %c = icmp sgt i32 %x, -1
14 %e = zext i1 %c to i32
18 define i32 @add_zext_ifpos(i32 %x) {
19 ; CHECK-LABEL: add_zext_ifpos:
21 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
22 ; CHECK-NEXT: sarl $31, %edi
23 ; CHECK-NEXT: leal 42(%rdi), %eax
25 %c = icmp sgt i32 %x, -1
26 %e = zext i1 %c to i32
31 define <4 x i32> @add_zext_ifpos_vec_splat(<4 x i32> %x) {
32 ; CHECK-LABEL: add_zext_ifpos_vec_splat:
34 ; CHECK-NEXT: pcmpeqd %xmm1, %xmm1
35 ; CHECK-NEXT: pcmpgtd %xmm1, %xmm0
36 ; CHECK-NEXT: movdqa {{.*#+}} xmm1 = [42,42,42,42]
37 ; CHECK-NEXT: psubd %xmm0, %xmm1
38 ; CHECK-NEXT: movdqa %xmm1, %xmm0
40 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
41 %e = zext <4 x i1> %c to <4 x i32>
42 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
46 define <4 x i32> @add_zext_ifpos_vec_nonsplat(<4 x i32> %x) {
47 ; CHECK-LABEL: add_zext_ifpos_vec_nonsplat:
49 ; CHECK-NEXT: pcmpeqd %xmm1, %xmm1
50 ; CHECK-NEXT: pcmpgtd %xmm1, %xmm0
51 ; CHECK-NEXT: movdqa {{.*#+}} xmm1 = [42,43,44,45]
52 ; CHECK-NEXT: psubd %xmm0, %xmm1
53 ; CHECK-NEXT: movdqa %xmm1, %xmm0
55 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
56 %e = zext <4 x i1> %c to <4 x i32>
57 %r = add <4 x i32> %e, <i32 42, i32 43, i32 44, i32 45>
61 define i32 @sel_ifpos_tval_bigger(i32 %x) {
62 ; CHECK-LABEL: sel_ifpos_tval_bigger:
64 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
65 ; CHECK-NEXT: sarl $31, %edi
66 ; CHECK-NEXT: leal 42(%rdi), %eax
68 %c = icmp sgt i32 %x, -1
69 %r = select i1 %c, i32 42, i32 41
73 define i32 @sext_ifpos(i32 %x) {
74 ; CHECK-LABEL: sext_ifpos:
76 ; CHECK-NEXT: movl %edi, %eax
77 ; CHECK-NEXT: notl %eax
78 ; CHECK-NEXT: sarl $31, %eax
80 %c = icmp sgt i32 %x, -1
81 %e = sext i1 %c to i32
85 define i32 @add_sext_ifpos(i32 %x) {
86 ; CHECK-LABEL: add_sext_ifpos:
88 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
89 ; CHECK-NEXT: shrl $31, %edi
90 ; CHECK-NEXT: leal 41(%rdi), %eax
92 %c = icmp sgt i32 %x, -1
93 %e = sext i1 %c to i32
98 define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) {
99 ; CHECK-LABEL: add_sext_ifpos_vec_splat:
101 ; CHECK-NEXT: pcmpeqd %xmm1, %xmm1
102 ; CHECK-NEXT: pcmpgtd %xmm1, %xmm0
103 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
105 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
106 %e = sext <4 x i1> %c to <4 x i32>
107 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
111 define <4 x i32> @add_sext_ifpos_vec_nonsplat(<4 x i32> %x) {
112 ; CHECK-LABEL: add_sext_ifpos_vec_nonsplat:
114 ; CHECK-NEXT: pcmpeqd %xmm1, %xmm1
115 ; CHECK-NEXT: pcmpgtd %xmm1, %xmm0
116 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
118 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
119 %e = sext <4 x i1> %c to <4 x i32>
120 %r = add <4 x i32> %e, <i32 42, i32 43, i32 44, i32 45>
124 define i32 @sel_ifpos_fval_bigger(i32 %x) {
125 ; CHECK-LABEL: sel_ifpos_fval_bigger:
127 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
128 ; CHECK-NEXT: shrl $31, %edi
129 ; CHECK-NEXT: leal 41(%rdi), %eax
131 %c = icmp sgt i32 %x, -1
132 %r = select i1 %c, i32 41, i32 42
138 define i32 @zext_ifneg(i32 %x) {
139 ; CHECK-LABEL: zext_ifneg:
141 ; CHECK-NEXT: movl %edi, %eax
142 ; CHECK-NEXT: shrl $31, %eax
144 %c = icmp slt i32 %x, 0
145 %r = zext i1 %c to i32
149 define i32 @add_zext_ifneg(i32 %x) {
150 ; CHECK-LABEL: add_zext_ifneg:
152 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
153 ; CHECK-NEXT: shrl $31, %edi
154 ; CHECK-NEXT: leal 41(%rdi), %eax
156 %c = icmp slt i32 %x, 0
157 %e = zext i1 %c to i32
162 define i32 @sel_ifneg_tval_bigger(i32 %x) {
163 ; CHECK-LABEL: sel_ifneg_tval_bigger:
165 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
166 ; CHECK-NEXT: shrl $31, %edi
167 ; CHECK-NEXT: leal 41(%rdi), %eax
169 %c = icmp slt i32 %x, 0
170 %r = select i1 %c, i32 42, i32 41
174 define i32 @sext_ifneg(i32 %x) {
175 ; CHECK-LABEL: sext_ifneg:
177 ; CHECK-NEXT: movl %edi, %eax
178 ; CHECK-NEXT: sarl $31, %eax
180 %c = icmp slt i32 %x, 0
181 %r = sext i1 %c to i32
185 define i32 @add_sext_ifneg(i32 %x) {
186 ; CHECK-LABEL: add_sext_ifneg:
188 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
189 ; CHECK-NEXT: sarl $31, %edi
190 ; CHECK-NEXT: leal 42(%rdi), %eax
192 %c = icmp slt i32 %x, 0
193 %e = sext i1 %c to i32
198 define i32 @sel_ifneg_fval_bigger(i32 %x) {
199 ; CHECK-LABEL: sel_ifneg_fval_bigger:
201 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
202 ; CHECK-NEXT: sarl $31, %edi
203 ; CHECK-NEXT: leal 42(%rdi), %eax
205 %c = icmp slt i32 %x, 0
206 %r = select i1 %c, i32 41, i32 42
210 define i32 @add_lshr_not(i32 %x) {
211 ; CHECK-LABEL: add_lshr_not:
213 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
214 ; CHECK-NEXT: sarl $31, %edi
215 ; CHECK-NEXT: leal 42(%rdi), %eax
217 %not = xor i32 %x, -1
218 %sh = lshr i32 %not, 31
223 define <4 x i32> @add_lshr_not_vec_splat(<4 x i32> %x) {
224 ; CHECK-LABEL: add_lshr_not_vec_splat:
226 ; CHECK-NEXT: psrad $31, %xmm0
227 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
229 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
230 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
231 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
235 define <4 x i32> @add_lshr_not_vec_nonsplat(<4 x i32> %x) {
236 ; CHECK-LABEL: add_lshr_not_vec_nonsplat:
238 ; CHECK-NEXT: psrad $31, %xmm0
239 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
241 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
242 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
243 %r = add <4 x i32> %e, <i32 42, i32 43, i32 44, i32 45>
247 define i32 @sub_lshr_not(i32 %x) {
248 ; CHECK-LABEL: sub_lshr_not:
250 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
251 ; CHECK-NEXT: shrl $31, %edi
252 ; CHECK-NEXT: leal 42(%rdi), %eax
254 %not = xor i32 %x, -1
255 %sh = lshr i32 %not, 31
260 define <4 x i32> @sub_lshr_not_vec_splat(<4 x i32> %x) {
261 ; CHECK-LABEL: sub_lshr_not_vec_splat:
263 ; CHECK-NEXT: psrld $31, %xmm0
264 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
266 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
267 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
268 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %e
272 define <4 x i32> @sub_lshr_not_vec_nonsplat(<4 x i32> %x) {
273 ; CHECK-LABEL: sub_lshr_not_vec_nonsplat:
275 ; CHECK-NEXT: psrld $31, %xmm0
276 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
278 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
279 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
280 %r = sub <4 x i32> <i32 42, i32 43, i32 44, i32 45>, %e
284 define i32 @sub_lshr(i32 %x, i32 %y) {
285 ; CHECK-LABEL: sub_lshr:
287 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
288 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
289 ; CHECK-NEXT: sarl $31, %edi
290 ; CHECK-NEXT: leal (%rdi,%rsi), %eax
292 %sh = lshr i32 %x, 31
297 define <4 x i32> @sub_lshr_vec(<4 x i32> %x, <4 x i32> %y) {
298 ; CHECK-LABEL: sub_lshr_vec:
300 ; CHECK-NEXT: psrad $31, %xmm0
301 ; CHECK-NEXT: paddd %xmm1, %xmm0
303 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
304 %r = sub <4 x i32> %y, %sh
308 define i32 @sub_const_op_lshr(i32 %x) {
309 ; CHECK-LABEL: sub_const_op_lshr:
311 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
312 ; CHECK-NEXT: sarl $31, %edi
313 ; CHECK-NEXT: leal 43(%rdi), %eax
315 %sh = lshr i32 %x, 31
320 define <4 x i32> @sub_const_op_lshr_vec_splat(<4 x i32> %x) {
321 ; CHECK-LABEL: sub_const_op_lshr_vec_splat:
323 ; CHECK-NEXT: psrad $31, %xmm0
324 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
326 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
327 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %sh
331 define <4 x i32> @sub_const_op_lshr_vec_nonsplat(<4 x i32> %x) {
332 ; CHECK-LABEL: sub_const_op_lshr_vec_nonsplat:
334 ; CHECK-NEXT: psrad $31, %xmm0
335 ; CHECK-NEXT: paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
337 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
338 %r = sub <4 x i32> <i32 42, i32 43, i32 44, i32 45>, %sh