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: psrld $31, %xmm0
37 ; CHECK-NEXT: por {{.*}}(%rip), %xmm0
39 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
40 %e = zext <4 x i1> %c to <4 x i32>
41 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
45 define i32 @sel_ifpos_tval_bigger(i32 %x) {
46 ; CHECK-LABEL: sel_ifpos_tval_bigger:
48 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
49 ; CHECK-NEXT: sarl $31, %edi
50 ; CHECK-NEXT: leal 42(%rdi), %eax
52 %c = icmp sgt i32 %x, -1
53 %r = select i1 %c, i32 42, i32 41
57 define i32 @sext_ifpos(i32 %x) {
58 ; CHECK-LABEL: sext_ifpos:
60 ; CHECK-NEXT: movl %edi, %eax
61 ; CHECK-NEXT: notl %eax
62 ; CHECK-NEXT: sarl $31, %eax
64 %c = icmp sgt i32 %x, -1
65 %e = sext i1 %c to i32
69 define i32 @add_sext_ifpos(i32 %x) {
70 ; CHECK-LABEL: add_sext_ifpos:
72 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
73 ; CHECK-NEXT: shrl $31, %edi
74 ; CHECK-NEXT: leal 41(%rdi), %eax
76 %c = icmp sgt i32 %x, -1
77 %e = sext i1 %c to i32
82 define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) {
83 ; CHECK-LABEL: add_sext_ifpos_vec_splat:
85 ; CHECK-NEXT: pcmpeqd %xmm1, %xmm1
86 ; CHECK-NEXT: pcmpgtd %xmm1, %xmm0
87 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
89 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
90 %e = sext <4 x i1> %c to <4 x i32>
91 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
95 define i32 @sel_ifpos_fval_bigger(i32 %x) {
96 ; CHECK-LABEL: sel_ifpos_fval_bigger:
98 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
99 ; CHECK-NEXT: shrl $31, %edi
100 ; CHECK-NEXT: leal 41(%rdi), %eax
102 %c = icmp sgt i32 %x, -1
103 %r = select i1 %c, i32 41, i32 42
109 define i32 @zext_ifneg(i32 %x) {
110 ; CHECK-LABEL: zext_ifneg:
112 ; CHECK-NEXT: movl %edi, %eax
113 ; CHECK-NEXT: shrl $31, %eax
115 %c = icmp slt i32 %x, 0
116 %r = zext i1 %c to i32
120 define i32 @add_zext_ifneg(i32 %x) {
121 ; CHECK-LABEL: add_zext_ifneg:
123 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
124 ; CHECK-NEXT: shrl $31, %edi
125 ; CHECK-NEXT: leal 41(%rdi), %eax
127 %c = icmp slt i32 %x, 0
128 %e = zext i1 %c to i32
133 define i32 @sel_ifneg_tval_bigger(i32 %x) {
134 ; CHECK-LABEL: sel_ifneg_tval_bigger:
136 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
137 ; CHECK-NEXT: shrl $31, %edi
138 ; CHECK-NEXT: leal 41(%rdi), %eax
140 %c = icmp slt i32 %x, 0
141 %r = select i1 %c, i32 42, i32 41
145 define i32 @sext_ifneg(i32 %x) {
146 ; CHECK-LABEL: sext_ifneg:
148 ; CHECK-NEXT: movl %edi, %eax
149 ; CHECK-NEXT: sarl $31, %eax
151 %c = icmp slt i32 %x, 0
152 %r = sext i1 %c to i32
156 define i32 @add_sext_ifneg(i32 %x) {
157 ; CHECK-LABEL: add_sext_ifneg:
159 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
160 ; CHECK-NEXT: sarl $31, %edi
161 ; CHECK-NEXT: leal 42(%rdi), %eax
163 %c = icmp slt i32 %x, 0
164 %e = sext i1 %c to i32
169 define i32 @sel_ifneg_fval_bigger(i32 %x) {
170 ; CHECK-LABEL: sel_ifneg_fval_bigger:
172 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
173 ; CHECK-NEXT: sarl $31, %edi
174 ; CHECK-NEXT: leal 42(%rdi), %eax
176 %c = icmp slt i32 %x, 0
177 %r = select i1 %c, i32 41, i32 42
181 define i32 @add_lshr_not(i32 %x) {
182 ; CHECK-LABEL: add_lshr_not:
184 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
185 ; CHECK-NEXT: sarl $31, %edi
186 ; CHECK-NEXT: leal 42(%rdi), %eax
188 %not = xor i32 %x, -1
189 %sh = lshr i32 %not, 31
194 define <4 x i32> @add_lshr_not_vec_splat(<4 x i32> %x) {
195 ; CHECK-LABEL: add_lshr_not_vec_splat:
197 ; CHECK-NEXT: psrad $31, %xmm0
198 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
200 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
201 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
202 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
206 define i32 @sub_lshr_not(i32 %x) {
207 ; CHECK-LABEL: sub_lshr_not:
209 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
210 ; CHECK-NEXT: shrl $31, %edi
211 ; CHECK-NEXT: leal 42(%rdi), %eax
213 %not = xor i32 %x, -1
214 %sh = lshr i32 %not, 31
219 define <4 x i32> @sub_lshr_not_vec_splat(<4 x i32> %x) {
220 ; CHECK-LABEL: sub_lshr_not_vec_splat:
222 ; CHECK-NEXT: psrld $31, %xmm0
223 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
225 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
226 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
227 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %e
231 define i32 @sub_lshr(i32 %x, i32 %y) {
232 ; CHECK-LABEL: sub_lshr:
234 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
235 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
236 ; CHECK-NEXT: sarl $31, %edi
237 ; CHECK-NEXT: leal (%rdi,%rsi), %eax
239 %sh = lshr i32 %x, 31
244 define <4 x i32> @sub_lshr_vec(<4 x i32> %x, <4 x i32> %y) {
245 ; CHECK-LABEL: sub_lshr_vec:
247 ; CHECK-NEXT: psrad $31, %xmm0
248 ; CHECK-NEXT: paddd %xmm1, %xmm0
250 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
251 %r = sub <4 x i32> %y, %sh
255 define i32 @sub_const_op_lshr(i32 %x) {
256 ; CHECK-LABEL: sub_const_op_lshr:
258 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
259 ; CHECK-NEXT: sarl $31, %edi
260 ; CHECK-NEXT: leal 43(%rdi), %eax
262 %sh = lshr i32 %x, 31
267 define <4 x i32> @sub_const_op_lshr_vec(<4 x i32> %x) {
268 ; CHECK-LABEL: sub_const_op_lshr_vec:
270 ; CHECK-NEXT: psrad $31, %xmm0
271 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
273 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
274 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %sh