1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i386-- -mattr=sse2 | FileCheck %s --check-prefixes=X32,X32_SSE,X32_SSE2
3 ; RUN: llc < %s -mtriple=i386-- -mattr=sse4.1 | FileCheck %s --check-prefixes=X32,X32_SSE,X32_SSE4
4 ; RUN: llc < %s -mtriple=i386-- -mattr=avx2 | FileCheck %s --check-prefixes=X32,X32_AVX,X32_AVX2
5 ; RUN: llc < %s -mtriple=i386-- -mattr=avx512f | FileCheck %s --check-prefixes=X32,X32_AVX,X32_AVX512F
6 ; RUN: llc < %s -mtriple=x86_64-- -mattr=sse2 | FileCheck %s --check-prefixes=X64,X64_SSE,X64_SSE2
7 ; RUN: llc < %s -mtriple=x86_64-- -mattr=sse4.1 | FileCheck %s --check-prefixes=X64,X64_SSE,X64_SSE4
8 ; RUN: llc < %s -mtriple=x86_64-- -mattr=avx2 | FileCheck %s --check-prefixes=X64,X64_AVX,X64_AVX2
9 ; RUN: llc < %s -mtriple=x86_64-- -mattr=avx512f | FileCheck %s --check-prefixes=X64,X64_AVX,X64_AVX512F
11 ; This should do a single load into the fp stack for the return, not diddle with xmm registers.
13 define float @icmp_select_fp_constants(i32 %x) nounwind readnone {
14 ; X32-LABEL: icmp_select_fp_constants:
16 ; X32-NEXT: xorl %eax, %eax
17 ; X32-NEXT: cmpl $0, {{[0-9]+}}(%esp)
19 ; X32-NEXT: flds {{\.LCPI.*}}(,%eax,4)
22 ; X64_SSE-LABEL: icmp_select_fp_constants:
24 ; X64_SSE-NEXT: xorl %eax, %eax
25 ; X64_SSE-NEXT: testl %edi, %edi
26 ; X64_SSE-NEXT: sete %al
27 ; X64_SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
30 ; X64_AVX-LABEL: icmp_select_fp_constants:
32 ; X64_AVX-NEXT: xorl %eax, %eax
33 ; X64_AVX-NEXT: testl %edi, %edi
34 ; X64_AVX-NEXT: sete %al
35 ; X64_AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
37 %c = icmp eq i32 %x, 0
38 %r = select i1 %c, float 42.0, float 23.0
42 define float @fcmp_select_fp_constants(float %x) nounwind readnone {
43 ; X32_SSE-LABEL: fcmp_select_fp_constants:
45 ; X32_SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
46 ; X32_SSE-NEXT: cmpneqss {{[0-9]+}}(%esp), %xmm0
47 ; X32_SSE-NEXT: movd %xmm0, %eax
48 ; X32_SSE-NEXT: andl $1, %eax
49 ; X32_SSE-NEXT: flds {{\.LCPI.*}}(,%eax,4)
52 ; X32_AVX2-LABEL: fcmp_select_fp_constants:
54 ; X32_AVX2-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
55 ; X32_AVX2-NEXT: vcmpneqss {{[0-9]+}}(%esp), %xmm0, %xmm0
56 ; X32_AVX2-NEXT: vmovd %xmm0, %eax
57 ; X32_AVX2-NEXT: andl $1, %eax
58 ; X32_AVX2-NEXT: flds {{\.LCPI.*}}(,%eax,4)
61 ; X32_AVX512F-LABEL: fcmp_select_fp_constants:
62 ; X32_AVX512F: # %bb.0:
63 ; X32_AVX512F-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
64 ; X32_AVX512F-NEXT: vcmpneqss {{[0-9]+}}(%esp), %xmm0, %k0
65 ; X32_AVX512F-NEXT: kmovw %k0, %eax
66 ; X32_AVX512F-NEXT: flds {{\.LCPI.*}}(,%eax,4)
67 ; X32_AVX512F-NEXT: retl
69 ; X64_SSE-LABEL: fcmp_select_fp_constants:
71 ; X64_SSE-NEXT: cmpneqss {{.*}}(%rip), %xmm0
72 ; X64_SSE-NEXT: movd %xmm0, %eax
73 ; X64_SSE-NEXT: andl $1, %eax
74 ; X64_SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
77 ; X64_AVX2-LABEL: fcmp_select_fp_constants:
79 ; X64_AVX2-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
80 ; X64_AVX2-NEXT: vmovss {{.*#+}} xmm2 = mem[0],zero,zero,zero
81 ; X64_AVX2-NEXT: vcmpneqss {{.*}}(%rip), %xmm0, %xmm0
82 ; X64_AVX2-NEXT: vblendvps %xmm0, %xmm1, %xmm2, %xmm0
85 ; X64_AVX512F-LABEL: fcmp_select_fp_constants:
86 ; X64_AVX512F: # %bb.0:
87 ; X64_AVX512F-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
88 ; X64_AVX512F-NEXT: vcmpneqss {{.*}}(%rip), %xmm0, %k1
89 ; X64_AVX512F-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
90 ; X64_AVX512F-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
91 ; X64_AVX512F-NEXT: retq
92 %c = fcmp une float %x, -4.0
93 %r = select i1 %c, float 42.0, float 23.0