1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=VI -check-prefix=FUNC %s
3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
6 ; DAGCombiner will transform:
7 ; (fabs (f32 bitcast (i32 a))) => (f32 bitcast (and (i32 a), 0x7FFFFFFF))
8 ; unless isFabsFree returns true
10 ; FUNC-LABEL: {{^}}fabs_fn_free:
12 ; R600: |PV.{{[XYZW]}}|
16 define void @fabs_fn_free(float addrspace(1)* %out, i32 %in) {
17 %bc= bitcast i32 %in to float
18 %fabs = call float @fabs(float %bc)
19 store float %fabs, float addrspace(1)* %out
23 ; FUNC-LABEL: {{^}}fabs_free:
25 ; R600: |PV.{{[XYZW]}}|
29 define void @fabs_free(float addrspace(1)* %out, i32 %in) {
30 %bc= bitcast i32 %in to float
31 %fabs = call float @llvm.fabs.f32(float %bc)
32 store float %fabs, float addrspace(1)* %out
36 ; FUNC-LABEL: {{^}}fabs_f32:
37 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
40 define void @fabs_f32(float addrspace(1)* %out, float %in) {
41 %fabs = call float @llvm.fabs.f32(float %in)
42 store float %fabs, float addrspace(1)* %out
46 ; FUNC-LABEL: {{^}}fabs_v2f32:
47 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
48 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
52 define void @fabs_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %in) {
53 %fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %in)
54 store <2 x float> %fabs, <2 x float> addrspace(1)* %out
58 ; FUNC-LABEL: {{^}}fabs_v4f32:
59 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
60 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
61 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
62 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
68 define void @fabs_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %in) {
69 %fabs = call <4 x float> @llvm.fabs.v4f32(<4 x float> %in)
70 store <4 x float> %fabs, <4 x float> addrspace(1)* %out
74 ; GCN-LABEL: {{^}}fabs_fn_fold:
75 ; SI: s_load_dword [[ABS_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0xb
76 ; VI: s_load_dword [[ABS_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0x2c
78 ; GCN: v_mul_f32_e64 v{{[0-9]+}}, |[[ABS_VALUE]]|, v{{[0-9]+}}
79 define void @fabs_fn_fold(float addrspace(1)* %out, float %in0, float %in1) {
80 %fabs = call float @fabs(float %in0)
81 %fmul = fmul float %fabs, %in1
82 store float %fmul, float addrspace(1)* %out
86 ; GCN-LABEL: {{^}}fabs_fold:
87 ; SI: s_load_dword [[ABS_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0xb
88 ; VI: s_load_dword [[ABS_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0x2c
90 ; GCN: v_mul_f32_e64 v{{[0-9]+}}, |[[ABS_VALUE]]|, v{{[0-9]+}}
91 define void @fabs_fold(float addrspace(1)* %out, float %in0, float %in1) {
92 %fabs = call float @llvm.fabs.f32(float %in0)
93 %fmul = fmul float %fabs, %in1
94 store float %fmul, float addrspace(1)* %out
98 declare float @fabs(float) readnone
99 declare float @llvm.fabs.f32(float) readnone
100 declare <2 x float> @llvm.fabs.v2f32(<2 x float>) readnone
101 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) readnone