1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx| FileCheck %s
3 ; Verify that we generate a single OR instruction for a scalar, vec128, and vec256
4 ; FNABS(x) operation -> FNEG (FABS(x)).
5 ; If the FABS() result isn't used, the AND instruction should be eliminated.
6 ; PR20578: http://llvm.org/bugs/show_bug.cgi?id=20578
8 define float @scalar_no_abs(float %a) {
9 ; CHECK-LABEL: scalar_no_abs:
12 %fabs = tail call float @fabsf(float %a) #1
13 %fsub = fsub float -0.0, %fabs
17 define float @scalar_uses_abs(float %a) {
18 ; CHECK-LABEL: scalar_uses_abs:
23 %fabs = tail call float @fabsf(float %a) #1
24 %fsub = fsub float -0.0, %fabs
25 %fmul = fmul float %fsub, %fabs
29 define <4 x float> @vector128_no_abs(<4 x float> %a) {
30 ; CHECK-LABEL: vector128_no_abs:
33 %fabs = tail call <4 x float> @llvm.fabs.v4f32(< 4 x float> %a) #1
34 %fsub = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %fabs
38 define <4 x float> @vector128_uses_abs(<4 x float> %a) {
39 ; CHECK-LABEL: vector128_uses_abs:
44 %fabs = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %a) #1
45 %fsub = fsub <4 x float> <float -0.0, float -0.0, float -0.0, float -0.0>, %fabs
46 %fmul = fmul <4 x float> %fsub, %fabs
50 define <8 x float> @vector256_no_abs(<8 x float> %a) {
51 ; CHECK-LABEL: vector256_no_abs:
54 %fabs = tail call <8 x float> @llvm.fabs.v8f32(< 8 x float> %a) #1
55 %fsub = fsub <8 x float> <float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0>, %fabs
59 define <8 x float> @vector256_uses_abs(<8 x float> %a) {
60 ; CHECK-LABEL: vector256_uses_abs:
65 %fabs = tail call <8 x float> @llvm.fabs.v8f32(<8 x float> %a) #1
66 %fsub = fsub <8 x float> <float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0, float -0.0>, %fabs
67 %fmul = fmul <8 x float> %fsub, %fabs
71 declare <4 x float> @llvm.fabs.v4f32(<4 x float> %p)
72 declare <8 x float> @llvm.fabs.v8f32(<8 x float> %p)
74 declare float @fabsf(float)
76 attributes #1 = { readnone }