1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mcpu=knl | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=knl | FileCheck %s --check-prefix=X64
5 define <16 x i32> @select00(i32 %a, <16 x i32> %b) nounwind {
8 ; X86-NEXT: cmpl $255, {{[0-9]+}}(%esp)
9 ; X86-NEXT: vpxor %xmm1, %xmm1, %xmm1
10 ; X86-NEXT: je .LBB0_2
12 ; X86-NEXT: vmovdqa64 %zmm0, %zmm1
14 ; X86-NEXT: vpxord %zmm1, %zmm0, %zmm0
17 ; X64-LABEL: select00:
19 ; X64-NEXT: cmpl $255, %edi
20 ; X64-NEXT: vpxor %xmm1, %xmm1, %xmm1
21 ; X64-NEXT: je .LBB0_2
23 ; X64-NEXT: vmovdqa64 %zmm0, %zmm1
25 ; X64-NEXT: vpxord %zmm1, %zmm0, %zmm0
27 %cmpres = icmp eq i32 %a, 255
28 %selres = select i1 %cmpres, <16 x i32> zeroinitializer, <16 x i32> %b
29 %res = xor <16 x i32> %b, %selres
33 define <8 x i64> @select01(i32 %a, <8 x i64> %b) nounwind {
34 ; X86-LABEL: select01:
36 ; X86-NEXT: cmpl $255, {{[0-9]+}}(%esp)
37 ; X86-NEXT: vpxor %xmm1, %xmm1, %xmm1
38 ; X86-NEXT: je .LBB1_2
40 ; X86-NEXT: vmovdqa64 %zmm0, %zmm1
42 ; X86-NEXT: vpxorq %zmm1, %zmm0, %zmm0
45 ; X64-LABEL: select01:
47 ; X64-NEXT: cmpl $255, %edi
48 ; X64-NEXT: vpxor %xmm1, %xmm1, %xmm1
49 ; X64-NEXT: je .LBB1_2
51 ; X64-NEXT: vmovdqa64 %zmm0, %zmm1
53 ; X64-NEXT: vpxorq %zmm1, %zmm0, %zmm0
55 %cmpres = icmp eq i32 %a, 255
56 %selres = select i1 %cmpres, <8 x i64> zeroinitializer, <8 x i64> %b
57 %res = xor <8 x i64> %b, %selres
61 define float @select02(float %a, float %b, float %c, float %eps) {
62 ; X86-LABEL: select02:
64 ; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
65 ; X86-NEXT: vucomiss {{[0-9]+}}(%esp), %xmm0
66 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
67 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
68 ; X86-NEXT: cmovael %eax, %ecx
69 ; X86-NEXT: flds (%ecx)
72 ; X64-LABEL: select02:
74 ; X64-NEXT: vcmpless %xmm0, %xmm3, %k1
75 ; X64-NEXT: vmovss %xmm2, %xmm0, %xmm1 {%k1}
76 ; X64-NEXT: vmovaps %xmm1, %xmm0
78 %cmp = fcmp oge float %a, %eps
79 %cond = select i1 %cmp, float %c, float %b
83 define double @select03(double %a, double %b, double %c, double %eps) {
84 ; X86-LABEL: select03:
86 ; X86-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
87 ; X86-NEXT: vucomisd {{[0-9]+}}(%esp), %xmm0
88 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
89 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
90 ; X86-NEXT: cmovael %eax, %ecx
91 ; X86-NEXT: fldl (%ecx)
94 ; X64-LABEL: select03:
96 ; X64-NEXT: vcmplesd %xmm0, %xmm3, %k1
97 ; X64-NEXT: vmovsd %xmm2, %xmm0, %xmm1 {%k1}
98 ; X64-NEXT: vmovapd %xmm1, %xmm0
100 %cmp = fcmp oge double %a, %eps
101 %cond = select i1 %cmp, double %c, double %b
105 define <16 x double> @select04(<16 x double> %a, <16 x double> %b) {
106 ; X86-LABEL: select04:
108 ; X86-NEXT: pushl %ebp
109 ; X86-NEXT: .cfi_def_cfa_offset 8
110 ; X86-NEXT: .cfi_offset %ebp, -8
111 ; X86-NEXT: movl %esp, %ebp
112 ; X86-NEXT: .cfi_def_cfa_register %ebp
113 ; X86-NEXT: andl $-64, %esp
114 ; X86-NEXT: subl $64, %esp
115 ; X86-NEXT: vmovaps 8(%ebp), %zmm1
116 ; X86-NEXT: movl %ebp, %esp
117 ; X86-NEXT: popl %ebp
118 ; X86-NEXT: .cfi_def_cfa %esp, 4
121 ; X64-LABEL: select04:
123 ; X64-NEXT: vmovaps %zmm3, %zmm1
125 %sel = select <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <16 x double> %a, <16 x double> %b
126 ret <16 x double> %sel
129 define i8 @select05(i8 %a.0, i8 %m) {
130 ; X86-LABEL: select05:
132 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
133 ; X86-NEXT: orb {{[0-9]+}}(%esp), %al
136 ; X64-LABEL: select05:
138 ; X64-NEXT: movl %edi, %eax
139 ; X64-NEXT: orl %esi, %eax
140 ; X64-NEXT: # kill: def $al killed $al killed $eax
142 %mask = bitcast i8 %m to <8 x i1>
143 %a = bitcast i8 %a.0 to <8 x i1>
144 %r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
145 %res = bitcast <8 x i1> %r to i8
149 define i8 @select05_mem(<8 x i1>* %a.0, <8 x i1>* %m) {
150 ; X86-LABEL: select05_mem:
152 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
153 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
154 ; X86-NEXT: kmovw (%ecx), %k0
155 ; X86-NEXT: kmovw (%eax), %k1
156 ; X86-NEXT: korw %k1, %k0, %k0
157 ; X86-NEXT: kmovw %k0, %eax
158 ; X86-NEXT: # kill: def $al killed $al killed $eax
161 ; X64-LABEL: select05_mem:
163 ; X64-NEXT: kmovw (%rsi), %k0
164 ; X64-NEXT: kmovw (%rdi), %k1
165 ; X64-NEXT: korw %k1, %k0, %k0
166 ; X64-NEXT: kmovw %k0, %eax
167 ; X64-NEXT: # kill: def $al killed $al killed $eax
169 %mask = load <8 x i1> , <8 x i1>* %m
170 %a = load <8 x i1> , <8 x i1>* %a.0
171 %r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
172 %res = bitcast <8 x i1> %r to i8
176 define i8 @select06(i8 %a.0, i8 %m) {
177 ; X86-LABEL: select06:
179 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
180 ; X86-NEXT: andb {{[0-9]+}}(%esp), %al
183 ; X64-LABEL: select06:
185 ; X64-NEXT: movl %edi, %eax
186 ; X64-NEXT: andl %esi, %eax
187 ; X64-NEXT: # kill: def $al killed $al killed $eax
189 %mask = bitcast i8 %m to <8 x i1>
190 %a = bitcast i8 %a.0 to <8 x i1>
191 %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
192 %res = bitcast <8 x i1> %r to i8
196 define i8 @select06_mem(<8 x i1>* %a.0, <8 x i1>* %m) {
197 ; X86-LABEL: select06_mem:
199 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
200 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
201 ; X86-NEXT: kmovw (%ecx), %k0
202 ; X86-NEXT: kmovw (%eax), %k1
203 ; X86-NEXT: kandw %k1, %k0, %k0
204 ; X86-NEXT: kmovw %k0, %eax
205 ; X86-NEXT: # kill: def $al killed $al killed $eax
208 ; X64-LABEL: select06_mem:
210 ; X64-NEXT: kmovw (%rsi), %k0
211 ; X64-NEXT: kmovw (%rdi), %k1
212 ; X64-NEXT: kandw %k1, %k0, %k0
213 ; X64-NEXT: kmovw %k0, %eax
214 ; X64-NEXT: # kill: def $al killed $al killed $eax
216 %mask = load <8 x i1> , <8 x i1>* %m
217 %a = load <8 x i1> , <8 x i1>* %a.0
218 %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
219 %res = bitcast <8 x i1> %r to i8
222 define i8 @select07(i8 %a.0, i8 %b.0, i8 %m) {
223 ; X86-LABEL: select07:
225 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
226 ; X86-NEXT: kmovw %eax, %k0
227 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
228 ; X86-NEXT: kmovw %eax, %k1
229 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
230 ; X86-NEXT: kmovw %eax, %k2
231 ; X86-NEXT: kandnw %k2, %k0, %k2
232 ; X86-NEXT: kandw %k0, %k1, %k0
233 ; X86-NEXT: korw %k2, %k0, %k0
234 ; X86-NEXT: kmovw %k0, %eax
235 ; X86-NEXT: # kill: def $al killed $al killed $eax
238 ; X64-LABEL: select07:
240 ; X64-NEXT: kmovw %edx, %k0
241 ; X64-NEXT: kmovw %edi, %k1
242 ; X64-NEXT: kmovw %esi, %k2
243 ; X64-NEXT: kandnw %k2, %k0, %k2
244 ; X64-NEXT: kandw %k0, %k1, %k0
245 ; X64-NEXT: korw %k2, %k0, %k0
246 ; X64-NEXT: kmovw %k0, %eax
247 ; X64-NEXT: # kill: def $al killed $al killed $eax
249 %mask = bitcast i8 %m to <8 x i1>
250 %a = bitcast i8 %a.0 to <8 x i1>
251 %b = bitcast i8 %b.0 to <8 x i1>
252 %r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> %b
253 %res = bitcast <8 x i1> %r to i8
257 define i64 @pr30249() {
258 ; X86-LABEL: pr30249:
260 ; X86-NEXT: movl $1, %eax
261 ; X86-NEXT: xorl %edx, %edx
264 ; X64-LABEL: pr30249:
266 ; X64-NEXT: movl $1, %eax
268 %v = select i1 undef , i64 1, i64 2
272 define double @pr30561_f64(double %b, double %a, i1 %c) {
273 ; X86-LABEL: pr30561_f64:
275 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
276 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
277 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
278 ; X86-NEXT: cmovnel %eax, %ecx
279 ; X86-NEXT: fldl (%ecx)
282 ; X64-LABEL: pr30561_f64:
284 ; X64-NEXT: kmovw %edi, %k1
285 ; X64-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
287 %cond = select i1 %c, double %a, double %b
291 define float @pr30561_f32(float %b, float %a, i1 %c) {
292 ; X86-LABEL: pr30561_f32:
294 ; X86-NEXT: testb $1, {{[0-9]+}}(%esp)
295 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
296 ; X86-NEXT: leal {{[0-9]+}}(%esp), %ecx
297 ; X86-NEXT: cmovnel %eax, %ecx
298 ; X86-NEXT: flds (%ecx)
301 ; X64-LABEL: pr30561_f32:
303 ; X64-NEXT: kmovw %edi, %k1
304 ; X64-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
306 %cond = select i1 %c, float %a, float %b
310 define <16 x i16> @pr31515(<16 x i1> %a, <16 x i1> %b, <16 x i16> %c) nounwind {
311 ; X86-LABEL: pr31515:
313 ; X86-NEXT: vpand %xmm1, %xmm0, %xmm0
314 ; X86-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
315 ; X86-NEXT: vpsllw $15, %ymm0, %ymm0
316 ; X86-NEXT: vpsraw $15, %ymm0, %ymm0
317 ; X86-NEXT: vpandn %ymm2, %ymm0, %ymm0
320 ; X64-LABEL: pr31515:
322 ; X64-NEXT: vpand %xmm1, %xmm0, %xmm0
323 ; X64-NEXT: vpmovzxbw {{.*#+}} ymm0 = xmm0[0],zero,xmm0[1],zero,xmm0[2],zero,xmm0[3],zero,xmm0[4],zero,xmm0[5],zero,xmm0[6],zero,xmm0[7],zero,xmm0[8],zero,xmm0[9],zero,xmm0[10],zero,xmm0[11],zero,xmm0[12],zero,xmm0[13],zero,xmm0[14],zero,xmm0[15],zero
324 ; X64-NEXT: vpsllw $15, %ymm0, %ymm0
325 ; X64-NEXT: vpsraw $15, %ymm0, %ymm0
326 ; X64-NEXT: vpandn %ymm2, %ymm0, %ymm0
328 %mask = and <16 x i1> %a, %b
329 %res = select <16 x i1> %mask, <16 x i16> zeroinitializer, <16 x i16> %c