1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X64
6 ; PR48768 - 'xor' clears the overflow flag, so we don't need a separate 'test'.
9 define i8 @xor_i8_ri(i8 zeroext %0, i8 zeroext %1) {
10 ; X86-LABEL: xor_i8_ri:
12 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
13 ; X86-NEXT: movl %eax, %ecx
14 ; X86-NEXT: xorb $-17, %cl
15 ; X86-NEXT: je .LBB0_2
17 ; X86-NEXT: movl %ecx, %eax
21 ; X64-LABEL: xor_i8_ri:
23 ; X64-NEXT: movl %edi, %eax
24 ; X64-NEXT: xorb $-17, %al
25 ; X64-NEXT: movzbl %al, %eax
26 ; X64-NEXT: cmovel %edi, %eax
27 ; X64-NEXT: # kill: def $al killed $al killed $eax
31 %5 = select i1 %4, i8 %0, i8 %3
35 define i8 @xor_i8_rr(i8 zeroext %0, i8 zeroext %1) {
36 ; X86-LABEL: xor_i8_rr:
38 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
39 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
40 ; X86-NEXT: xorb %al, %cl
41 ; X86-NEXT: je .LBB1_2
43 ; X86-NEXT: movl %ecx, %eax
47 ; X64-LABEL: xor_i8_rr:
49 ; X64-NEXT: movl %esi, %eax
50 ; X64-NEXT: xorl %edi, %eax
51 ; X64-NEXT: cmovel %edi, %eax
52 ; X64-NEXT: # kill: def $al killed $al killed $eax
56 %5 = select i1 %4, i8 %0, i8 %3
60 define i16 @xor_i16_ri(i16 zeroext %0, i16 zeroext %1) {
61 ; X86-LABEL: xor_i16_ri:
63 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
64 ; X86-NEXT: movl %eax, %ecx
65 ; X86-NEXT: xorl $-17, %ecx
66 ; X86-NEXT: testw %cx, %cx
67 ; X86-NEXT: je .LBB2_2
69 ; X86-NEXT: movl %ecx, %eax
71 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
74 ; X64-LABEL: xor_i16_ri:
76 ; X64-NEXT: movl %edi, %eax
77 ; X64-NEXT: xorl $-17, %eax
78 ; X64-NEXT: testw %ax, %ax
79 ; X64-NEXT: cmovel %edi, %eax
80 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
83 %4 = icmp eq i16 %3, 0
84 %5 = select i1 %4, i16 %0, i16 %3
88 define i16 @xor_i16_rr(i16 zeroext %0, i16 zeroext %1) {
89 ; X86-LABEL: xor_i16_rr:
91 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
92 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
93 ; X86-NEXT: xorw %ax, %cx
94 ; X86-NEXT: je .LBB3_2
96 ; X86-NEXT: movl %ecx, %eax
98 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
101 ; X64-LABEL: xor_i16_rr:
103 ; X64-NEXT: movl %esi, %eax
104 ; X64-NEXT: xorl %edi, %eax
105 ; X64-NEXT: cmovel %edi, %eax
106 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
109 %4 = icmp eq i16 %3, 0
110 %5 = select i1 %4, i16 %0, i16 %3
114 define i32 @xor_i32_ri(i32 %0, i32 %1) {
115 ; X86-LABEL: xor_i32_ri:
117 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
118 ; X86-NEXT: movl %eax, %ecx
119 ; X86-NEXT: xorl $-17, %ecx
120 ; X86-NEXT: jle .LBB4_2
122 ; X86-NEXT: movl %ecx, %eax
126 ; X64-LABEL: xor_i32_ri:
128 ; X64-NEXT: movl %edi, %eax
129 ; X64-NEXT: xorl $-17, %eax
130 ; X64-NEXT: cmovlel %edi, %eax
133 %4 = icmp slt i32 %3, 1
134 %5 = select i1 %4, i32 %0, i32 %3
138 define i32 @xor_i32_rr(i32 %0, i32 %1) {
139 ; X86-LABEL: xor_i32_rr:
141 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
142 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
143 ; X86-NEXT: xorl %eax, %ecx
144 ; X86-NEXT: jle .LBB5_2
146 ; X86-NEXT: movl %ecx, %eax
150 ; X64-LABEL: xor_i32_rr:
152 ; X64-NEXT: movl %esi, %eax
153 ; X64-NEXT: xorl %edi, %eax
154 ; X64-NEXT: cmovlel %edi, %eax
157 %4 = icmp slt i32 %3, 1
158 %5 = select i1 %4, i32 %0, i32 %3
162 define i64 @xor_i64_ri(i64 %0, i64 %1) nounwind {
163 ; X86-LABEL: xor_i64_ri:
165 ; X86-NEXT: pushl %edi
166 ; X86-NEXT: pushl %esi
167 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
168 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
169 ; X86-NEXT: movl %edx, %ecx
170 ; X86-NEXT: notl %ecx
171 ; X86-NEXT: movl %eax, %esi
172 ; X86-NEXT: xorl $-17, %esi
173 ; X86-NEXT: cmpl $1, %esi
174 ; X86-NEXT: movl %ecx, %edi
175 ; X86-NEXT: sbbl $0, %edi
176 ; X86-NEXT: jl .LBB6_2
178 ; X86-NEXT: movl %esi, %eax
179 ; X86-NEXT: movl %ecx, %edx
181 ; X86-NEXT: popl %esi
182 ; X86-NEXT: popl %edi
185 ; X64-LABEL: xor_i64_ri:
187 ; X64-NEXT: movq %rdi, %rax
188 ; X64-NEXT: xorq $-17, %rax
189 ; X64-NEXT: cmovleq %rdi, %rax
192 %4 = icmp slt i64 %3, 1
193 %5 = select i1 %4, i64 %0, i64 %3
197 define i64 @xor_i64_rr(i64 %0, i64 %1) nounwind {
198 ; X86-LABEL: xor_i64_rr:
200 ; X86-NEXT: pushl %edi
201 ; X86-NEXT: pushl %esi
202 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
203 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
204 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
205 ; X86-NEXT: xorl %edx, %ecx
206 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
207 ; X86-NEXT: xorl %eax, %esi
208 ; X86-NEXT: cmpl $1, %esi
209 ; X86-NEXT: movl %ecx, %edi
210 ; X86-NEXT: sbbl $0, %edi
211 ; X86-NEXT: jl .LBB7_2
213 ; X86-NEXT: movl %esi, %eax
214 ; X86-NEXT: movl %ecx, %edx
216 ; X86-NEXT: popl %esi
217 ; X86-NEXT: popl %edi
220 ; X64-LABEL: xor_i64_rr:
222 ; X64-NEXT: movq %rsi, %rax
223 ; X64-NEXT: xorq %rdi, %rax
224 ; X64-NEXT: cmovleq %rdi, %rax
227 %4 = icmp slt i64 %3, 1
228 %5 = select i1 %4, i64 %0, i64 %3