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 i32 @sel_ifpos_tval_bigger(i32 %x) {
47 ; CHECK-LABEL: sel_ifpos_tval_bigger:
49 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
50 ; CHECK-NEXT: sarl $31, %edi
51 ; CHECK-NEXT: leal 42(%rdi), %eax
53 %c = icmp sgt i32 %x, -1
54 %r = select i1 %c, i32 42, i32 41
58 define i32 @sext_ifpos(i32 %x) {
59 ; CHECK-LABEL: sext_ifpos:
61 ; CHECK-NEXT: movl %edi, %eax
62 ; CHECK-NEXT: notl %eax
63 ; CHECK-NEXT: sarl $31, %eax
65 %c = icmp sgt i32 %x, -1
66 %e = sext i1 %c to i32
70 define i32 @add_sext_ifpos(i32 %x) {
71 ; CHECK-LABEL: add_sext_ifpos:
73 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
74 ; CHECK-NEXT: shrl $31, %edi
75 ; CHECK-NEXT: leal 41(%rdi), %eax
77 %c = icmp sgt i32 %x, -1
78 %e = sext i1 %c to i32
83 define <4 x i32> @add_sext_ifpos_vec_splat(<4 x i32> %x) {
84 ; CHECK-LABEL: add_sext_ifpos_vec_splat:
86 ; CHECK-NEXT: pcmpeqd %xmm1, %xmm1
87 ; CHECK-NEXT: pcmpgtd %xmm1, %xmm0
88 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
90 %c = icmp sgt <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
91 %e = sext <4 x i1> %c to <4 x i32>
92 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
96 define i32 @sel_ifpos_fval_bigger(i32 %x) {
97 ; CHECK-LABEL: sel_ifpos_fval_bigger:
99 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
100 ; CHECK-NEXT: shrl $31, %edi
101 ; CHECK-NEXT: leal 41(%rdi), %eax
103 %c = icmp sgt i32 %x, -1
104 %r = select i1 %c, i32 41, i32 42
110 define i32 @zext_ifneg(i32 %x) {
111 ; CHECK-LABEL: zext_ifneg:
113 ; CHECK-NEXT: movl %edi, %eax
114 ; CHECK-NEXT: shrl $31, %eax
116 %c = icmp slt i32 %x, 0
117 %r = zext i1 %c to i32
121 define i32 @add_zext_ifneg(i32 %x) {
122 ; CHECK-LABEL: add_zext_ifneg:
124 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
125 ; CHECK-NEXT: shrl $31, %edi
126 ; CHECK-NEXT: leal 41(%rdi), %eax
128 %c = icmp slt i32 %x, 0
129 %e = zext i1 %c to i32
134 define i32 @sel_ifneg_tval_bigger(i32 %x) {
135 ; CHECK-LABEL: sel_ifneg_tval_bigger:
137 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
138 ; CHECK-NEXT: shrl $31, %edi
139 ; CHECK-NEXT: leal 41(%rdi), %eax
141 %c = icmp slt i32 %x, 0
142 %r = select i1 %c, i32 42, i32 41
146 define i32 @sext_ifneg(i32 %x) {
147 ; CHECK-LABEL: sext_ifneg:
149 ; CHECK-NEXT: movl %edi, %eax
150 ; CHECK-NEXT: sarl $31, %eax
152 %c = icmp slt i32 %x, 0
153 %r = sext i1 %c to i32
157 define i32 @add_sext_ifneg(i32 %x) {
158 ; CHECK-LABEL: add_sext_ifneg:
160 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
161 ; CHECK-NEXT: sarl $31, %edi
162 ; CHECK-NEXT: leal 42(%rdi), %eax
164 %c = icmp slt i32 %x, 0
165 %e = sext i1 %c to i32
170 define i32 @sel_ifneg_fval_bigger(i32 %x) {
171 ; CHECK-LABEL: sel_ifneg_fval_bigger:
173 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
174 ; CHECK-NEXT: sarl $31, %edi
175 ; CHECK-NEXT: leal 42(%rdi), %eax
177 %c = icmp slt i32 %x, 0
178 %r = select i1 %c, i32 41, i32 42
182 define i32 @add_lshr_not(i32 %x) {
183 ; CHECK-LABEL: add_lshr_not:
185 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
186 ; CHECK-NEXT: sarl $31, %edi
187 ; CHECK-NEXT: leal 42(%rdi), %eax
189 %not = xor i32 %x, -1
190 %sh = lshr i32 %not, 31
195 define <4 x i32> @add_lshr_not_vec_splat(<4 x i32> %x) {
196 ; CHECK-LABEL: add_lshr_not_vec_splat:
198 ; CHECK-NEXT: psrad $31, %xmm0
199 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
201 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
202 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
203 %r = add <4 x i32> %e, <i32 42, i32 42, i32 42, i32 42>
207 define i32 @sub_lshr_not(i32 %x) {
208 ; CHECK-LABEL: sub_lshr_not:
210 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
211 ; CHECK-NEXT: shrl $31, %edi
212 ; CHECK-NEXT: leal 42(%rdi), %eax
214 %not = xor i32 %x, -1
215 %sh = lshr i32 %not, 31
220 define <4 x i32> @sub_lshr_not_vec_splat(<4 x i32> %x) {
221 ; CHECK-LABEL: sub_lshr_not_vec_splat:
223 ; CHECK-NEXT: psrld $31, %xmm0
224 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
226 %c = xor <4 x i32> %x, <i32 -1, i32 -1, i32 -1, i32 -1>
227 %e = lshr <4 x i32> %c, <i32 31, i32 31, i32 31, i32 31>
228 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %e
232 define i32 @sub_lshr(i32 %x, i32 %y) {
233 ; CHECK-LABEL: sub_lshr:
235 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
236 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
237 ; CHECK-NEXT: sarl $31, %edi
238 ; CHECK-NEXT: leal (%rdi,%rsi), %eax
240 %sh = lshr i32 %x, 31
245 define <4 x i32> @sub_lshr_vec(<4 x i32> %x, <4 x i32> %y) {
246 ; CHECK-LABEL: sub_lshr_vec:
248 ; CHECK-NEXT: psrad $31, %xmm0
249 ; CHECK-NEXT: paddd %xmm1, %xmm0
251 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
252 %r = sub <4 x i32> %y, %sh
256 define i32 @sub_const_op_lshr(i32 %x) {
257 ; CHECK-LABEL: sub_const_op_lshr:
259 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
260 ; CHECK-NEXT: sarl $31, %edi
261 ; CHECK-NEXT: leal 43(%rdi), %eax
263 %sh = lshr i32 %x, 31
268 define <4 x i32> @sub_const_op_lshr_vec(<4 x i32> %x) {
269 ; CHECK-LABEL: sub_const_op_lshr_vec:
271 ; CHECK-NEXT: psrad $31, %xmm0
272 ; CHECK-NEXT: paddd {{.*}}(%rip), %xmm0
274 %sh = lshr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
275 %r = sub <4 x i32> <i32 42, i32 42, i32 42, i32 42>, %sh