1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefix=X64
3 ; RUN: llc < %s -mtriple=i686-- | FileCheck %s --check-prefix=X32
5 define i32 @sub_zext_cmp_mask_same_size_result(i32 %x) {
6 ; X64-LABEL: sub_zext_cmp_mask_same_size_result:
8 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
9 ; X64-NEXT: andl $1, %edi
10 ; X64-NEXT: leal -28(%rdi), %eax
13 ; X32-LABEL: sub_zext_cmp_mask_same_size_result:
15 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
16 ; X32-NEXT: andl $1, %eax
17 ; X32-NEXT: orl $-28, %eax
20 %c = icmp eq i32 %a, 0
21 %z = zext i1 %c to i32
26 define i32 @sub_zext_cmp_mask_wider_result(i8 %x) {
27 ; X64-LABEL: sub_zext_cmp_mask_wider_result:
29 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
30 ; X64-NEXT: andl $1, %edi
31 ; X64-NEXT: leal 26(%rdi), %eax
34 ; X32-LABEL: sub_zext_cmp_mask_wider_result:
36 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
37 ; X32-NEXT: andl $1, %eax
38 ; X32-NEXT: orl $26, %eax
42 %z = zext i1 %c to i32
47 define i8 @sub_zext_cmp_mask_narrower_result(i32 %x) {
48 ; X64-LABEL: sub_zext_cmp_mask_narrower_result:
50 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
51 ; X64-NEXT: andb $1, %dil
52 ; X64-NEXT: leal 46(%rdi), %eax
53 ; X64-NEXT: # kill: def $al killed $al killed $eax
56 ; X32-LABEL: sub_zext_cmp_mask_narrower_result:
58 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
59 ; X32-NEXT: andb $1, %al
60 ; X32-NEXT: orb $46, %al
63 %c = icmp eq i32 %a, 0
69 define i8 @add_zext_cmp_mask_same_size_result(i8 %x) {
70 ; X64-LABEL: add_zext_cmp_mask_same_size_result:
72 ; X64-NEXT: movl %edi, %eax
73 ; X64-NEXT: andb $1, %al
74 ; X64-NEXT: xorb $27, %al
75 ; X64-NEXT: # kill: def $al killed $al killed $eax
78 ; X32-LABEL: add_zext_cmp_mask_same_size_result:
80 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
81 ; X32-NEXT: andb $1, %al
82 ; X32-NEXT: xorb $27, %al
91 define i32 @add_zext_cmp_mask_wider_result(i8 %x) {
92 ; X64-LABEL: add_zext_cmp_mask_wider_result:
94 ; X64-NEXT: movl %edi, %eax
95 ; X64-NEXT: andl $1, %eax
96 ; X64-NEXT: xorl $27, %eax
99 ; X32-LABEL: add_zext_cmp_mask_wider_result:
101 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
102 ; X32-NEXT: andl $1, %eax
103 ; X32-NEXT: xorl $27, %eax
106 %c = icmp eq i8 %a, 0
107 %z = zext i1 %c to i32
112 define i8 @add_zext_cmp_mask_narrower_result(i32 %x) {
113 ; X64-LABEL: add_zext_cmp_mask_narrower_result:
115 ; X64-NEXT: movl %edi, %eax
116 ; X64-NEXT: andb $1, %al
117 ; X64-NEXT: xorb $43, %al
118 ; X64-NEXT: # kill: def $al killed $al killed $eax
121 ; X32-LABEL: add_zext_cmp_mask_narrower_result:
123 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
124 ; X32-NEXT: andb $1, %al
125 ; X32-NEXT: xorb $43, %al
128 %c = icmp eq i32 %a, 0
129 %z = zext i1 %c to i8
134 define i32 @low_bit_select_constants_bigger_false_same_size_result(i32 %x) {
135 ; X64-LABEL: low_bit_select_constants_bigger_false_same_size_result:
137 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
138 ; X64-NEXT: andl $1, %edi
139 ; X64-NEXT: leal 42(%rdi), %eax
142 ; X32-LABEL: low_bit_select_constants_bigger_false_same_size_result:
144 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
145 ; X32-NEXT: andl $1, %eax
146 ; X32-NEXT: orl $42, %eax
149 %c = icmp eq i32 %a, 0
150 %r = select i1 %c, i32 42, i32 43
154 define i64 @low_bit_select_constants_bigger_false_wider_result(i32 %x) {
155 ; X64-LABEL: low_bit_select_constants_bigger_false_wider_result:
157 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
158 ; X64-NEXT: andl $1, %edi
159 ; X64-NEXT: leaq 26(%rdi), %rax
162 ; X32-LABEL: low_bit_select_constants_bigger_false_wider_result:
164 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
165 ; X32-NEXT: andl $1, %eax
166 ; X32-NEXT: orl $26, %eax
167 ; X32-NEXT: xorl %edx, %edx
170 %c = icmp eq i32 %a, 0
171 %r = select i1 %c, i64 26, i64 27
175 define i16 @low_bit_select_constants_bigger_false_narrower_result(i32 %x) {
176 ; X64-LABEL: low_bit_select_constants_bigger_false_narrower_result:
178 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
179 ; X64-NEXT: andl $1, %edi
180 ; X64-NEXT: leal 36(%rdi), %eax
181 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
184 ; X32-LABEL: low_bit_select_constants_bigger_false_narrower_result:
186 ; X32-NEXT: movzwl {{[0-9]+}}(%esp), %eax
187 ; X32-NEXT: andl $1, %eax
188 ; X32-NEXT: orl $36, %eax
189 ; X32-NEXT: # kill: def $ax killed $ax killed $eax
192 %c = icmp eq i32 %a, 0
193 %r = select i1 %c, i16 36, i16 37
197 define i8 @low_bit_select_constants_bigger_true_same_size_result(i8 %x) {
198 ; X64-LABEL: low_bit_select_constants_bigger_true_same_size_result:
200 ; X64-NEXT: movl %edi, %eax
201 ; X64-NEXT: andb $1, %al
202 ; X64-NEXT: xorb $-29, %al
203 ; X64-NEXT: # kill: def $al killed $al killed $eax
206 ; X32-LABEL: low_bit_select_constants_bigger_true_same_size_result:
208 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
209 ; X32-NEXT: andb $1, %al
210 ; X32-NEXT: xorb $-29, %al
213 %c = icmp eq i8 %a, 0
214 %r = select i1 %c, i8 227, i8 226
218 define i32 @low_bit_select_constants_bigger_true_wider_result(i8 %x) {
219 ; X64-LABEL: low_bit_select_constants_bigger_true_wider_result:
221 ; X64-NEXT: movl %edi, %eax
222 ; X64-NEXT: andl $1, %eax
223 ; X64-NEXT: xorl $227, %eax
226 ; X32-LABEL: low_bit_select_constants_bigger_true_wider_result:
228 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
229 ; X32-NEXT: andl $1, %eax
230 ; X32-NEXT: xorl $227, %eax
233 %c = icmp eq i8 %a, 0
234 %r = select i1 %c, i32 227, i32 226
238 define i8 @low_bit_select_constants_bigger_true_narrower_result(i16 %x) {
239 ; X64-LABEL: low_bit_select_constants_bigger_true_narrower_result:
241 ; X64-NEXT: movl %edi, %eax
242 ; X64-NEXT: andb $1, %al
243 ; X64-NEXT: xorb $41, %al
244 ; X64-NEXT: # kill: def $al killed $al killed $eax
247 ; X32-LABEL: low_bit_select_constants_bigger_true_narrower_result:
249 ; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
250 ; X32-NEXT: andb $1, %al
251 ; X32-NEXT: xorb $41, %al
254 %c = icmp eq i16 %a, 0
255 %r = select i1 %c, i8 41, i8 40
259 ; Truncation hoisting must not occur with opaque constants
260 ; because that can induce infinite looping.
262 define i1 @opaque_constant(i48 %x, i48 %y) {
263 ; X64-LABEL: opaque_constant:
265 ; X64-NEXT: movq %rdi, %rax
266 ; X64-NEXT: xorq %rsi, %rax
267 ; X64-NEXT: shrq $32, %rax
268 ; X64-NEXT: andl $1, %eax
269 ; X64-NEXT: # kill: def $al killed $al killed $rax
272 ; X32-LABEL: opaque_constant:
274 ; X32-NEXT: movl {{[0-9]+}}(%esp), %eax
275 ; X32-NEXT: xorl {{[0-9]+}}(%esp), %eax
276 ; X32-NEXT: andl $1, %eax
277 ; X32-NEXT: # kill: def $al killed $al killed $eax
279 %andx = and i48 %x, 4294967296
280 %andy = and i48 %y, 4294967296
281 %cmp1 = icmp ne i48 %andx, 0
282 %cmp2 = icmp ne i48 %andy, 0
283 %r = xor i1 %cmp1, %cmp2