Skip to content

Commit 41e0740

Browse files
committed
Add fcmp+select testcase
1 parent 4566628 commit 41e0740

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=SSE2
3+
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=AVX
4+
; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=X86
5+
6+
define dso_local noundef float @maxs(float noundef nofpclass(nan) %a, float noundef nofpclass(nan) %b) local_unnamed_addr #0 {
7+
; SSE2-LABEL: maxs:
8+
; SSE2: # %bb.0: # %entry
9+
; SSE2-NEXT: maxss %xmm1, %xmm0
10+
; SSE2-NEXT: retq
11+
;
12+
; AVX-LABEL: maxs:
13+
; AVX: # %bb.0: # %entry
14+
; AVX-NEXT: vmaxss %xmm1, %xmm0, %xmm0
15+
; AVX-NEXT: retq
16+
;
17+
; X86-LABEL: maxs:
18+
; X86: # %bb.0: # %entry
19+
; X86-NEXT: pushl %eax
20+
; X86-NEXT: .cfi_def_cfa_offset 8
21+
; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
22+
; X86-NEXT: vmaxss {{[0-9]+}}(%esp), %xmm0, %xmm0
23+
; X86-NEXT: vmovss %xmm0, (%esp)
24+
; X86-NEXT: flds (%esp)
25+
; X86-NEXT: popl %eax
26+
; X86-NEXT: .cfi_def_cfa_offset 4
27+
; X86-NEXT: retl
28+
entry:
29+
%cmp = fcmp ogt float %a, %b
30+
%cond = select i1 %cmp, float %a, float %b
31+
ret float %cond
32+
}
33+
34+
define dso_local noundef <8 x float> @maxs_v8f32(<8 x float> noundef nofpclass(nan) %a, <8 x float> noundef nofpclass(nan) %b) local_unnamed_addr #0 {
35+
; SSE2-LABEL: maxs_v8f32:
36+
; SSE2: # %bb.0: # %entry
37+
; SSE2-NEXT: maxps %xmm2, %xmm0
38+
; SSE2-NEXT: maxps %xmm3, %xmm1
39+
; SSE2-NEXT: retq
40+
;
41+
; AVX-LABEL: maxs_v8f32:
42+
; AVX: # %bb.0: # %entry
43+
; AVX-NEXT: vmaxps %ymm1, %ymm0, %ymm0
44+
; AVX-NEXT: retq
45+
;
46+
; X86-LABEL: maxs_v8f32:
47+
; X86: # %bb.0: # %entry
48+
; X86-NEXT: vmaxps %ymm1, %ymm0, %ymm0
49+
; X86-NEXT: retl
50+
entry:
51+
%cmp = fcmp ogt <8 x float> %a, %b
52+
%cond = select <8 x i1> %cmp, <8 x float> %a, <8 x float> %b
53+
ret <8 x float> %cond
54+
}
55+
56+
define dso_local noundef float @maxd(float noundef nofpclass(nan) %a, float noundef nofpclass(nan) %b) local_unnamed_addr #0 {
57+
; SSE2-LABEL: maxd:
58+
; SSE2: # %bb.0: # %entry
59+
; SSE2-NEXT: maxss %xmm1, %xmm0
60+
; SSE2-NEXT: retq
61+
;
62+
; AVX-LABEL: maxd:
63+
; AVX: # %bb.0: # %entry
64+
; AVX-NEXT: vmaxss %xmm1, %xmm0, %xmm0
65+
; AVX-NEXT: retq
66+
;
67+
; X86-LABEL: maxd:
68+
; X86: # %bb.0: # %entry
69+
; X86-NEXT: pushl %eax
70+
; X86-NEXT: .cfi_def_cfa_offset 8
71+
; X86-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
72+
; X86-NEXT: vmaxss {{[0-9]+}}(%esp), %xmm0, %xmm0
73+
; X86-NEXT: vmovss %xmm0, (%esp)
74+
; X86-NEXT: flds (%esp)
75+
; X86-NEXT: popl %eax
76+
; X86-NEXT: .cfi_def_cfa_offset 4
77+
; X86-NEXT: retl
78+
entry:
79+
%cmp = fcmp ogt float %a, %b
80+
%cond = select i1 %cmp, float %a, float %b
81+
ret float %cond
82+
}
83+
84+
define dso_local noundef <8 x double> @mind_v8f32(<8 x double> noundef nofpclass(nan) %a, <8 x double> noundef nofpclass(nan) %b) local_unnamed_addr #0 {
85+
; SSE2-LABEL: mind_v8f32:
86+
; SSE2: # %bb.0: # %entry
87+
; SSE2-NEXT: maxpd %xmm4, %xmm0
88+
; SSE2-NEXT: maxpd %xmm5, %xmm1
89+
; SSE2-NEXT: maxpd %xmm6, %xmm2
90+
; SSE2-NEXT: maxpd %xmm7, %xmm3
91+
; SSE2-NEXT: retq
92+
;
93+
; AVX-LABEL: mind_v8f32:
94+
; AVX: # %bb.0: # %entry
95+
; AVX-NEXT: vmaxpd %ymm2, %ymm0, %ymm0
96+
; AVX-NEXT: vmaxpd %ymm3, %ymm1, %ymm1
97+
; AVX-NEXT: retq
98+
;
99+
; X86-LABEL: mind_v8f32:
100+
; X86: # %bb.0: # %entry
101+
; X86-NEXT: pushl %ebp
102+
; X86-NEXT: .cfi_def_cfa_offset 8
103+
; X86-NEXT: .cfi_offset %ebp, -8
104+
; X86-NEXT: movl %esp, %ebp
105+
; X86-NEXT: .cfi_def_cfa_register %ebp
106+
; X86-NEXT: andl $-32, %esp
107+
; X86-NEXT: subl $32, %esp
108+
; X86-NEXT: vmaxpd %ymm2, %ymm0, %ymm0
109+
; X86-NEXT: vmaxpd 8(%ebp), %ymm1, %ymm1
110+
; X86-NEXT: movl %ebp, %esp
111+
; X86-NEXT: popl %ebp
112+
; X86-NEXT: .cfi_def_cfa %esp, 4
113+
; X86-NEXT: retl
114+
entry:
115+
%cmp = fcmp ogt <8 x double> %a, %b
116+
%cond = select <8 x i1> %cmp, <8 x double> %a, <8 x double> %b
117+
ret <8 x double> %cond
118+
}

0 commit comments

Comments
 (0)