1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefix=SSE
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx2 | FileCheck %s --check-prefix=AVX
5 ; NOTE: this is generated by utils/update_llc_test_checks.py but we can't check NAN types (PR30443),
6 ; so we need to edit it to remove the NAN constant comments
10 define float @combine_fabs_constant() {
11 ; SSE-LABEL: combine_fabs_constant:
13 ; SSE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
16 ; AVX-LABEL: combine_fabs_constant:
18 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
20 %1 = call float @llvm.fabs.f32(float -2.0)
24 define <4 x float> @combine_vec_fabs_constant() {
25 ; SSE-LABEL: combine_vec_fabs_constant:
27 ; SSE-NEXT: movaps {{.*#+}} xmm0 = [0.0E+0,0.0E+0,2.0E+0,2.0E+0]
30 ; AVX-LABEL: combine_vec_fabs_constant:
32 ; AVX-NEXT: vmovaps {{.*#+}} xmm0 = [0.0E+0,0.0E+0,2.0E+0,2.0E+0]
34 %1 = call <4 x float> @llvm.fabs.v4f32(<4 x float> <float 0.0, float -0.0, float 2.0, float -2.0>)
38 ; fabs(fabs(x)) -> fabs(x)
39 define float @combine_fabs_fabs(float %a) {
40 ; SSE-LABEL: combine_fabs_fabs:
42 ; SSE-NEXT: andps {{.*}}(%rip), %xmm0
45 ; AVX-LABEL: combine_fabs_fabs:
47 ; AVX-NEXT: vbroadcastss {{.*}}(%rip), %xmm1
48 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
50 %1 = call float @llvm.fabs.f32(float %a)
51 %2 = call float @llvm.fabs.f32(float %1)
55 define <4 x float> @combine_vec_fabs_fabs(<4 x float> %a) {
56 ; SSE-LABEL: combine_vec_fabs_fabs:
58 ; SSE-NEXT: andps {{.*}}(%rip), %xmm0
61 ; AVX-LABEL: combine_vec_fabs_fabs:
63 ; AVX-NEXT: vbroadcastss {{.*}}(%rip), %xmm1
64 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
66 %1 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %a)
67 %2 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %1)
71 ; fabs(fneg(x)) -> fabs(x)
72 define float @combine_fabs_fneg(float %a) {
73 ; SSE-LABEL: combine_fabs_fneg:
75 ; SSE-NEXT: andps {{.*}}(%rip), %xmm0
78 ; AVX-LABEL: combine_fabs_fneg:
80 ; AVX-NEXT: vbroadcastss {{.*}}(%rip), %xmm1
81 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
83 %1 = fsub float -0.0, %a
84 %2 = call float @llvm.fabs.f32(float %1)
88 define <4 x float> @combine_vec_fabs_fneg(<4 x float> %a) {
89 ; SSE-LABEL: combine_vec_fabs_fneg:
91 ; SSE-NEXT: andps {{.*}}(%rip), %xmm0
94 ; AVX-LABEL: combine_vec_fabs_fneg:
96 ; AVX-NEXT: vbroadcastss {{.*}}(%rip), %xmm1
97 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
99 %1 = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %a
100 %2 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %1)
104 ; fabs(fcopysign(x, y)) -> fabs(x)
105 define float @combine_fabs_fcopysign(float %a, float %b) {
106 ; SSE-LABEL: combine_fabs_fcopysign:
108 ; SSE-NEXT: andps {{.*}}(%rip), %xmm0
111 ; AVX-LABEL: combine_fabs_fcopysign:
113 ; AVX-NEXT: vbroadcastss {{.*}}(%rip), %xmm1
114 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
116 %1 = call float @llvm.copysign.f32(float %a, float %b)
117 %2 = call float @llvm.fabs.f32(float %1)
121 define <4 x float> @combine_vec_fabs_fcopysign(<4 x float> %a, <4 x float> %b) {
122 ; SSE-LABEL: combine_vec_fabs_fcopysign:
124 ; SSE-NEXT: andps {{.*}}(%rip), %xmm0
127 ; AVX-LABEL: combine_vec_fabs_fcopysign:
129 ; AVX-NEXT: vbroadcastss {{.*}}(%rip), %xmm1
130 ; AVX-NEXT: vandps %xmm1, %xmm0, %xmm0
132 %1 = call <4 x float> @llvm.copysign.v4f32(<4 x float> %a, <4 x float> %b)
133 %2 = call <4 x float> @llvm.fabs.v4f32(<4 x float> %1)
137 declare float @llvm.fabs.f32(float %p)
138 declare float @llvm.copysign.f32(float %Mag, float %Sgn)
140 declare <4 x float> @llvm.fabs.v4f32(<4 x float> %p)
141 declare <4 x float> @llvm.copysign.v4f32(<4 x float> %Mag, <4 x float> %Sgn)