1 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=sse2 < %s | FileCheck %s --check-prefix=CHECK --check-prefix=SSE
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=avx < %s | FileCheck %s --check-prefix=CHECK --check-prefix=AVX
4 declare float @fmaxf(float, float)
5 declare double @fmax(double, double)
6 declare x86_fp80 @fmaxl(x86_fp80, x86_fp80)
7 declare float @llvm.maxnum.f32(float, float)
8 declare double @llvm.maxnum.f64(double, double)
9 declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80)
11 declare <2 x float> @llvm.maxnum.v2f32(<2 x float>, <2 x float>)
12 declare <4 x float> @llvm.maxnum.v4f32(<4 x float>, <4 x float>)
13 declare <2 x double> @llvm.maxnum.v2f64(<2 x double>, <2 x double>)
14 declare <4 x double> @llvm.maxnum.v4f64(<4 x double>, <4 x double>)
15 declare <8 x double> @llvm.maxnum.v8f64(<8 x double>, <8 x double>)
18 ; CHECK-LABEL: @test_fmaxf
19 ; SSE: movaps %xmm0, %xmm2
20 ; SSE-NEXT: cmpunordss %xmm2, %xmm2
21 ; SSE-NEXT: movaps %xmm2, %xmm3
22 ; SSE-NEXT: andps %xmm1, %xmm3
23 ; SSE-NEXT: maxss %xmm0, %xmm1
24 ; SSE-NEXT: andnps %xmm1, %xmm2
25 ; SSE-NEXT: orps %xmm3, %xmm2
26 ; SSE-NEXT: movaps %xmm2, %xmm0
29 ; AVX: vmaxss %xmm0, %xmm1, %xmm2
30 ; AVX-NEXT: vcmpunordss %xmm0, %xmm0, %xmm0
31 ; AVX-NEXT: vblendvps %xmm0, %xmm1, %xmm2, %xmm0
33 define float @test_fmaxf(float %x, float %y) {
34 %z = call float @fmaxf(float %x, float %y) readnone
38 ; CHECK-LABEL: @test_fmaxf_minsize
40 define float @test_fmaxf_minsize(float %x, float %y) minsize {
41 %z = call float @fmaxf(float %x, float %y) readnone
45 ; FIXME: Doubles should be inlined similarly to floats.
47 ; CHECK-LABEL: @test_fmax
49 define double @test_fmax(double %x, double %y) {
50 %z = call double @fmax(double %x, double %y) readnone
54 ; CHECK-LABEL: @test_fmaxl
56 define x86_fp80 @test_fmaxl(x86_fp80 %x, x86_fp80 %y) {
57 %z = call x86_fp80 @fmaxl(x86_fp80 %x, x86_fp80 %y) readnone
61 ; CHECK-LABEL: @test_intrinsic_fmaxf
62 ; SSE: movaps %xmm0, %xmm2
63 ; SSE-NEXT: cmpunordss %xmm2, %xmm2
64 ; SSE-NEXT: movaps %xmm2, %xmm3
65 ; SSE-NEXT: andps %xmm1, %xmm3
66 ; SSE-NEXT: maxss %xmm0, %xmm1
67 ; SSE-NEXT: andnps %xmm1, %xmm2
68 ; SSE-NEXT: orps %xmm3, %xmm2
69 ; SSE-NEXT: movaps %xmm2, %xmm0
72 ; AVX: vmaxss %xmm0, %xmm1, %xmm2
73 ; AVX-NEXT: vcmpunordss %xmm0, %xmm0, %xmm0
74 ; AVX-NEXT: vblendvps %xmm0, %xmm1, %xmm2, %xmm0
76 define float @test_intrinsic_fmaxf(float %x, float %y) {
77 %z = call float @llvm.maxnum.f32(float %x, float %y) readnone
81 ; FIXME: Doubles should be inlined similarly to floats.
83 ; CHECK-LABEL: @test_intrinsic_fmax
85 define double @test_intrinsic_fmax(double %x, double %y) {
86 %z = call double @llvm.maxnum.f64(double %x, double %y) readnone
90 ; CHECK-LABEL: @test_intrinsic_fmaxl
92 define x86_fp80 @test_intrinsic_fmaxl(x86_fp80 %x, x86_fp80 %y) {
93 %z = call x86_fp80 @llvm.maxnum.f80(x86_fp80 %x, x86_fp80 %y) readnone
97 ; CHECK-LABEL: @test_intrinsic_fmax_v2f32
98 ; SSE: movaps %xmm1, %xmm2
99 ; SSE-NEXT: maxps %xmm0, %xmm2
100 ; SSE-NEXT: cmpunordps %xmm0, %xmm0
101 ; SSE-NEXT: andps %xmm0, %xmm1
102 ; SSE-NEXT: andnps %xmm2, %xmm0
103 ; SSE-NEXT: orps %xmm1, %xmm0
106 ; AVX: vmaxps %xmm0, %xmm1, %xmm2
107 ; AVX-NEXT: vcmpunordps %xmm0, %xmm0, %xmm0
108 ; AVX-NEXT: vblendvps %xmm0, %xmm1, %xmm2, %xmm0
110 define <2 x float> @test_intrinsic_fmax_v2f32(<2 x float> %x, <2 x float> %y) {
111 %z = call <2 x float> @llvm.maxnum.v2f32(<2 x float> %x, <2 x float> %y) readnone
115 ; CHECK-LABEL: @test_intrinsic_fmax_v4f32
116 ; SSE: movaps %xmm1, %xmm2
117 ; SSE-NEXT: maxps %xmm0, %xmm2
118 ; SSE-NEXT: cmpunordps %xmm0, %xmm0
119 ; SSE-NEXT: andps %xmm0, %xmm1
120 ; SSE-NEXT: andnps %xmm2, %xmm0
121 ; SSE-NEXT: orps %xmm1, %xmm0
124 ; AVX: vmaxps %xmm0, %xmm1, %xmm2
125 ; AVX-NEXT: vcmpunordps %xmm0, %xmm0, %xmm0
126 ; AVX-NEXT: vblendvps %xmm0, %xmm1, %xmm2, %xmm0
128 define <4 x float> @test_intrinsic_fmax_v4f32(<4 x float> %x, <4 x float> %y) {
129 %z = call <4 x float> @llvm.maxnum.v4f32(<4 x float> %x, <4 x float> %y) readnone
133 ; FIXME: Vector of doubles should be inlined similarly to vector of floats.
135 ; CHECK-LABEL: @test_intrinsic_fmax_v2f64
138 define <2 x double> @test_intrinsic_fmax_v2f64(<2 x double> %x, <2 x double> %y) {
139 %z = call <2 x double> @llvm.maxnum.v2f64(<2 x double> %x, <2 x double> %y) readnone
143 ; FIXME: Vector of doubles should be inlined similarly to vector of floats.
145 ; CHECK-LABEL: @test_intrinsic_fmax_v4f64
150 define <4 x double> @test_intrinsic_fmax_v4f64(<4 x double> %x, <4 x double> %y) {
151 %z = call <4 x double> @llvm.maxnum.v4f64(<4 x double> %x, <4 x double> %y) readnone
155 ; FIXME: Vector of doubles should be inlined similarly to vector of floats.
157 ; CHECK-LABEL: @test_intrinsic_fmax_v8f64
166 define <8 x double> @test_intrinsic_fmax_v8f64(<8 x double> %x, <8 x double> %y) {
167 %z = call <8 x double> @llvm.maxnum.v8f64(<8 x double> %x, <8 x double> %y) readnone