1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=X86
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=X64
5 declare i64 @llvm.abs.i64(i64, i1)
6 declare <2 x i64> @llvm.abs.2xi64(<2 x i64>, i1)
7 declare i32 @llvm.abs.i32(i32, i1)
8 declare i16 @llvm.abs.i16(i16, i1)
9 declare i8 @llvm.abs.i8(i8, i1)
11 define i1 @eq_pow_or(i32 %0) nounwind {
12 ; X86-LABEL: eq_pow_or:
14 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
15 ; X86-NEXT: addl $32, %eax
16 ; X86-NEXT: testl $-65, %eax
20 ; X64-LABEL: eq_pow_or:
22 ; X64-NEXT: addl $32, %edi
23 ; X64-NEXT: testl $-65, %edi
26 %2 = icmp eq i32 %0, 32
27 %3 = icmp eq i32 %0, -32
32 define i1 @ne_pow_and(i8 %0) nounwind {
33 ; X86-LABEL: ne_pow_and:
35 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
36 ; X86-NEXT: addb $16, %al
37 ; X86-NEXT: testb $-33, %al
41 ; X64-LABEL: ne_pow_and:
43 ; X64-NEXT: addb $16, %dil
44 ; X64-NEXT: testb $-33, %dil
47 %2 = icmp ne i8 %0, 16
48 %3 = icmp ne i8 %0, -16
53 define i1 @eq_pow_mismatch_or(i32 %0) nounwind {
54 ; X86-LABEL: eq_pow_mismatch_or:
56 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
57 ; X86-NEXT: cmpl $16, %eax
59 ; X86-NEXT: cmpl $-32, %eax
61 ; X86-NEXT: orb %cl, %al
64 ; X64-LABEL: eq_pow_mismatch_or:
66 ; X64-NEXT: cmpl $16, %edi
68 ; X64-NEXT: cmpl $-32, %edi
70 ; X64-NEXT: orb %cl, %al
72 %2 = icmp eq i32 %0, 16
73 %3 = icmp eq i32 %0, -32
78 define i1 @ne_non_pow_and(i8 %0) nounwind {
79 ; X86-LABEL: ne_non_pow_and:
81 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
82 ; X86-NEXT: cmpb $17, %al
84 ; X86-NEXT: cmpb $-17, %al
86 ; X86-NEXT: andb %cl, %al
89 ; X64-LABEL: ne_non_pow_and:
91 ; X64-NEXT: cmpb $17, %dil
93 ; X64-NEXT: cmpb $-17, %dil
95 ; X64-NEXT: andb %cl, %al
97 %2 = icmp ne i8 %0, 17
98 %3 = icmp ne i8 %0, -17
103 define i1 @ne_pow_or(i32 %0) nounwind {
104 ; X86-LABEL: ne_pow_or:
106 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
107 ; X86-NEXT: movl %eax, %ecx
108 ; X86-NEXT: xorl $32, %ecx
109 ; X86-NEXT: xorl $-32, %eax
110 ; X86-NEXT: orl %ecx, %eax
111 ; X86-NEXT: setne %al
114 ; X64-LABEL: ne_pow_or:
116 ; X64-NEXT: movl %edi, %eax
117 ; X64-NEXT: xorl $32, %eax
118 ; X64-NEXT: xorl $-32, %edi
119 ; X64-NEXT: orl %eax, %edi
120 ; X64-NEXT: setne %al
122 %2 = icmp ne i32 %0, 32
123 %3 = icmp ne i32 %0, -32
128 define i1 @eq_pow_and(i8 %0) nounwind {
129 ; X86-LABEL: eq_pow_and:
131 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
132 ; X86-NEXT: movl %eax, %ecx
133 ; X86-NEXT: xorb $16, %cl
134 ; X86-NEXT: xorb $-16, %al
135 ; X86-NEXT: orb %cl, %al
139 ; X64-LABEL: eq_pow_and:
141 ; X64-NEXT: movl %edi, %eax
142 ; X64-NEXT: xorb $16, %al
143 ; X64-NEXT: xorb $-16, %dil
144 ; X64-NEXT: orb %al, %dil
147 %2 = icmp eq i8 %0, 16
148 %3 = icmp eq i8 %0, -16
153 define i1 @abs_eq_pow2(i32 %0) nounwind {
154 ; X86-LABEL: abs_eq_pow2:
156 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
157 ; X86-NEXT: addl $4, %eax
158 ; X86-NEXT: testl $-9, %eax
162 ; X64-LABEL: abs_eq_pow2:
164 ; X64-NEXT: addl $4, %edi
165 ; X64-NEXT: testl $-9, %edi
168 %2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
169 %3 = icmp eq i32 %2, 4
173 define i1 @abs_ne_pow2(i64 %0) nounwind {
174 ; X86-LABEL: abs_ne_pow2:
176 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
177 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
178 ; X86-NEXT: addl $2, %eax
179 ; X86-NEXT: adcl $0, %ecx
180 ; X86-NEXT: andl $-5, %eax
181 ; X86-NEXT: orl %ecx, %eax
182 ; X86-NEXT: setne %al
185 ; X64-LABEL: abs_ne_pow2:
187 ; X64-NEXT: addq $2, %rdi
188 ; X64-NEXT: testq $-5, %rdi
189 ; X64-NEXT: setne %al
191 %2 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
192 %3 = icmp ne i64 %2, 2
196 define i1 @abs_ne_nonpow2(i16 %0) nounwind {
197 ; X86-LABEL: abs_ne_nonpow2:
199 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
200 ; X86-NEXT: movswl %ax, %ecx
201 ; X86-NEXT: sarl $15, %ecx
202 ; X86-NEXT: xorl %ecx, %eax
203 ; X86-NEXT: subl %ecx, %eax
204 ; X86-NEXT: movzwl %ax, %eax
205 ; X86-NEXT: cmpl $57344, %eax # imm = 0xE000
206 ; X86-NEXT: setne %al
209 ; X64-LABEL: abs_ne_nonpow2:
211 ; X64-NEXT: movl %edi, %eax
213 ; X64-NEXT: cmovsw %di, %ax
214 ; X64-NEXT: movzwl %ax, %eax
215 ; X64-NEXT: cmpl $57344, %eax # imm = 0xE000
216 ; X64-NEXT: setne %al
218 %2 = tail call i16 @llvm.abs.i16(i16 %0, i1 true)
219 %3 = icmp ne i16 %2, -8192
223 define <2 x i1> @abs_ne_vec(<2 x i64> %0) nounwind {
224 ; X86-LABEL: abs_ne_vec:
226 ; X86-NEXT: pushl %edi
227 ; X86-NEXT: pushl %esi
228 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
229 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
230 ; X86-NEXT: movl %ecx, %esi
231 ; X86-NEXT: sarl $31, %esi
232 ; X86-NEXT: xorl %esi, %ecx
233 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
234 ; X86-NEXT: xorl %esi, %edx
235 ; X86-NEXT: subl %esi, %edx
236 ; X86-NEXT: sbbl %esi, %ecx
237 ; X86-NEXT: movl %eax, %esi
238 ; X86-NEXT: sarl $31, %esi
239 ; X86-NEXT: xorl %esi, %eax
240 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
241 ; X86-NEXT: xorl %esi, %edi
242 ; X86-NEXT: subl %esi, %edi
243 ; X86-NEXT: sbbl %esi, %eax
244 ; X86-NEXT: xorl $8, %edi
245 ; X86-NEXT: orl %eax, %edi
246 ; X86-NEXT: setne %al
247 ; X86-NEXT: xorl $8, %edx
248 ; X86-NEXT: orl %ecx, %edx
249 ; X86-NEXT: setne %dl
250 ; X86-NEXT: popl %esi
251 ; X86-NEXT: popl %edi
254 ; X64-LABEL: abs_ne_vec:
256 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,1,3,3]
257 ; X64-NEXT: psrad $31, %xmm1
258 ; X64-NEXT: pxor %xmm1, %xmm0
259 ; X64-NEXT: psubq %xmm1, %xmm0
260 ; X64-NEXT: pcmpeqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
261 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,0,3,2]
262 ; X64-NEXT: pand %xmm1, %xmm0
263 ; X64-NEXT: pcmpeqd %xmm1, %xmm1
264 ; X64-NEXT: pxor %xmm1, %xmm0
266 %2 = tail call <2 x i64> @llvm.abs.2xi64(<2 x i64> %0, i1 true)
267 %3 = icmp ne <2 x i64> %2, <i64 8, i64 8>