8f75459ef909b041c9d660275f37d09528f81efd
[oota-llvm.git] / test / CodeGen / R600 / fneg-fabs.ll
1 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
3
4
5 ; DAGCombiner will transform:
6 ; (fabs (f32 bitcast (i32 a))) => (f32 bitcast (and (i32 a), 0x7FFFFFFF))
7 ; unless isFabsFree returns true
8
9 ; FUNC-LABEL: @fneg_fabs_free_f32
10 ; R600-NOT: AND
11 ; R600: |PV.{{[XYZW]}}|
12 ; R600: -PV
13
14 ; SI: V_OR_B32
15 define void @fneg_fabs_free_f32(float addrspace(1)* %out, i32 %in) {
16   %bc = bitcast i32 %in to float
17   %fabs = call float @llvm.fabs.f32(float %bc)
18   %fsub = fsub float -0.000000e+00, %fabs
19   store float %fsub, float addrspace(1)* %out
20   ret void
21 }
22
23 ; FUNC-LABEL: @fneg_fabs_fn_free_f32
24 ; R600-NOT: AND
25 ; R600: |PV.{{[XYZW]}}|
26 ; R600: -PV
27
28 ; SI: V_OR_B32
29 define void @fneg_fabs_fn_free_f32(float addrspace(1)* %out, i32 %in) {
30   %bc = bitcast i32 %in to float
31   %fabs = call float @fabs(float %bc)
32   %fsub = fsub float -0.000000e+00, %fabs
33   store float %fsub, float addrspace(1)* %out
34   ret void
35 }
36
37 ; FUNC-LABEL: @fneg_fabs_v2f32
38 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
39 ; R600: -PV
40 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
41 ; R600: -PV
42
43 ; SI: V_OR_B32
44 ; SI: V_OR_B32
45 define void @fneg_fabs_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %in) {
46   %fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %in)
47   %fsub = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %fabs
48   store <2 x float> %fsub, <2 x float> addrspace(1)* %out
49   ret void
50 }
51
52 ; FUNC-LABEL: @fneg_fabs_v4f32
53 ; SI: V_OR_B32
54 ; SI: V_OR_B32
55 ; SI: V_OR_B32
56 ; SI: V_OR_B32
57 define void @fneg_fabs_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %in) {
58   %fabs = call <4 x float> @llvm.fabs.v4f32(<4 x float> %in)
59   %fsub = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %fabs
60   store <4 x float> %fsub, <4 x float> addrspace(1)* %out
61   ret void
62 }
63
64 declare float @fabs(float) readnone
65 declare float @llvm.fabs.f32(float) readnone
66 declare <2 x float> @llvm.fabs.v2f32(<2 x float>) readnone
67 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) readnone