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=X86,X86-SSE
3 ; RUN: llc < %s -mtriple=i386-- -mattr=sse4.1 | FileCheck %s --check-prefixes=X86,X86-SSE
4 ; RUN: llc < %s -mtriple=i386-- -mattr=avx2 | FileCheck %s --check-prefixes=X86,X86-AVX2
5 ; RUN: llc < %s -mtriple=i386-- -mattr=avx512f | FileCheck %s --check-prefixes=X86,X86-AVX512F
6 ; RUN: llc < %s -mtriple=x86_64-- -mattr=sse2 | FileCheck %s --check-prefix=X64-SSE
7 ; RUN: llc < %s -mtriple=x86_64-- -mattr=sse4.1 | FileCheck %s --check-prefix=X64-SSE
8 ; RUN: llc < %s -mtriple=x86_64-- -mattr=avx2 | FileCheck %s --check-prefixes=X64-AVX,X64-AVX2
9 ; RUN: llc < %s -mtriple=x86_64-- -mattr=avx512f | FileCheck %s --check-prefixes=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 ; X86-LABEL: icmp_select_fp_constants:
16 ; X86-NEXT: xorl %eax, %eax
17 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
19 ; X86-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}(,%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 ; X86-SSE-LABEL: fcmp_select_fp_constants:
45 ; X86-SSE-NEXT: movss {{.*#+}} xmm0 = [-4.0E+0,0.0E+0,0.0E+0,0.0E+0]
46 ; X86-SSE-NEXT: cmpneqss {{[0-9]+}}(%esp), %xmm0
47 ; X86-SSE-NEXT: movd %xmm0, %eax
48 ; X86-SSE-NEXT: andl $1, %eax
49 ; X86-SSE-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}(,%eax,4)
52 ; X86-AVX2-LABEL: fcmp_select_fp_constants:
54 ; X86-AVX2-NEXT: vmovss {{.*#+}} xmm0 = [-4.0E+0,0.0E+0,0.0E+0,0.0E+0]
55 ; X86-AVX2-NEXT: vcmpneqss {{[0-9]+}}(%esp), %xmm0, %xmm0
56 ; X86-AVX2-NEXT: vmovd %xmm0, %eax
57 ; X86-AVX2-NEXT: andl $1, %eax
58 ; X86-AVX2-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}(,%eax,4)
61 ; X86-AVX512F-LABEL: fcmp_select_fp_constants:
62 ; X86-AVX512F: # %bb.0:
63 ; X86-AVX512F-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
64 ; X86-AVX512F-NEXT: vcmpneqss {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0, %k0
65 ; X86-AVX512F-NEXT: kmovw %k0, %eax
66 ; X86-AVX512F-NEXT: flds {{\.?LCPI[0-9]+_[0-9]+}}(,%eax,4)
67 ; X86-AVX512F-NEXT: retl
69 ; X64-SSE-LABEL: fcmp_select_fp_constants:
71 ; X64-SSE-NEXT: cmpneqss {{\.?LCPI[0-9]+_[0-9]+}}(%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: vcmpneqss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
80 ; X64-AVX2-NEXT: vbroadcastss {{.*#+}} xmm1 = [4.2E+1,4.2E+1,4.2E+1,4.2E+1]
81 ; X64-AVX2-NEXT: vbroadcastss {{.*#+}} xmm2 = [2.3E+1,2.3E+1,2.3E+1,2.3E+1]
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: vcmpneqss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %k1
88 ; X64-AVX512F-NEXT: vmovss {{.*#+}} xmm0 = [2.3E+1,0.0E+0,0.0E+0,0.0E+0]
89 ; X64-AVX512F-NEXT: vmovss {{.*#+}} xmm0 {%k1} = [4.2E+1,0.0E+0,0.0E+0,0.0E+0]
90 ; X64-AVX512F-NEXT: retq
91 %c = fcmp une float %x, -4.0
92 %r = select i1 %c, float 42.0, float 23.0