221
|
1 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -verify-machineinstrs < %s | FileCheck --check-prefixes=SI,FUNC %s
|
|
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck --check-prefixes=VI,FUNC %s
|
|
3 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=r600 -mcpu=redwood < %s | FileCheck --check-prefixes=R600,FUNC %s
|
150
|
4
|
236
|
5 ; FUNC-LABEL: {{^}}fneg_fabsf_fadd_f32:
|
150
|
6 ; SI-NOT: and
|
|
7 ; SI: v_sub_f32_e64 {{v[0-9]+}}, {{s[0-9]+}}, |{{v[0-9]+}}|
|
252
|
8 define amdgpu_kernel void @fneg_fabsf_fadd_f32(ptr addrspace(1) %out, float %x, float %y) {
|
150
|
9 %fabs = call float @llvm.fabs.f32(float %x)
|
|
10 %fsub = fsub float -0.000000e+00, %fabs
|
|
11 %fadd = fadd float %y, %fsub
|
252
|
12 store float %fadd, ptr addrspace(1) %out, align 4
|
150
|
13 ret void
|
|
14 }
|
|
15
|
236
|
16 ; FUNC-LABEL: {{^}}fneg_fabsf_fmul_f32:
|
150
|
17 ; SI-NOT: and
|
|
18 ; SI: v_mul_f32_e64 {{v[0-9]+}}, {{s[0-9]+}}, -|{{v[0-9]+}}|
|
|
19 ; SI-NOT: and
|
252
|
20 define amdgpu_kernel void @fneg_fabsf_fmul_f32(ptr addrspace(1) %out, float %x, float %y) {
|
150
|
21 %fabs = call float @llvm.fabs.f32(float %x)
|
|
22 %fsub = fsub float -0.000000e+00, %fabs
|
|
23 %fmul = fmul float %y, %fsub
|
252
|
24 store float %fmul, ptr addrspace(1) %out, align 4
|
150
|
25 ret void
|
|
26 }
|
|
27
|
|
28 ; DAGCombiner will transform:
|
236
|
29 ; (fabsf (f32 bitcast (i32 a))) => (f32 bitcast (and (i32 a), 0x7FFFFFFF))
|
150
|
30 ; unless isFabsFree returns true
|
|
31
|
236
|
32 ; FUNC-LABEL: {{^}}fneg_fabsf_free_f32:
|
150
|
33 ; R600-NOT: AND
|
|
34 ; R600: |PV.{{[XYZW]}}|
|
|
35 ; R600: -PV
|
|
36
|
|
37 ; SI: s_or_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80000000
|
|
38 ; VI: s_bitset1_b32 s{{[0-9]+}}, 31
|
252
|
39 define amdgpu_kernel void @fneg_fabsf_free_f32(ptr addrspace(1) %out, i32 %in) {
|
150
|
40 %bc = bitcast i32 %in to float
|
|
41 %fabs = call float @llvm.fabs.f32(float %bc)
|
|
42 %fsub = fsub float -0.000000e+00, %fabs
|
252
|
43 store float %fsub, ptr addrspace(1) %out
|
150
|
44 ret void
|
|
45 }
|
|
46
|
236
|
47 ; FUNC-LABEL: {{^}}fneg_fabsf_fn_free_f32:
|
150
|
48 ; R600-NOT: AND
|
|
49 ; R600: |PV.{{[XYZW]}}|
|
|
50 ; R600: -PV
|
|
51
|
|
52 ; SI: s_or_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80000000
|
252
|
53 define amdgpu_kernel void @fneg_fabsf_fn_free_f32(ptr addrspace(1) %out, i32 %in) {
|
150
|
54 %bc = bitcast i32 %in to float
|
236
|
55 %fabs = call float @fabsf(float %bc)
|
150
|
56 %fsub = fsub float -0.000000e+00, %fabs
|
252
|
57 store float %fsub, ptr addrspace(1) %out
|
150
|
58 ret void
|
|
59 }
|
|
60
|
236
|
61 ; FUNC-LABEL: {{^}}fneg_fabsf_f32:
|
150
|
62 ; SI: s_or_b32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80000000
|
252
|
63 define amdgpu_kernel void @fneg_fabsf_f32(ptr addrspace(1) %out, float %in) {
|
150
|
64 %fabs = call float @llvm.fabs.f32(float %in)
|
|
65 %fsub = fsub float -0.000000e+00, %fabs
|
252
|
66 store float %fsub, ptr addrspace(1) %out, align 4
|
150
|
67 ret void
|
|
68 }
|
|
69
|
236
|
70 ; FUNC-LABEL: {{^}}v_fneg_fabsf_f32:
|
150
|
71 ; SI: v_or_b32_e32 v{{[0-9]+}}, 0x80000000, v{{[0-9]+}}
|
252
|
72 define amdgpu_kernel void @v_fneg_fabsf_f32(ptr addrspace(1) %out, ptr addrspace(1) %in) {
|
|
73 %val = load float, ptr addrspace(1) %in, align 4
|
150
|
74 %fabs = call float @llvm.fabs.f32(float %val)
|
|
75 %fsub = fsub float -0.000000e+00, %fabs
|
252
|
76 store float %fsub, ptr addrspace(1) %out, align 4
|
150
|
77 ret void
|
|
78 }
|
|
79
|
236
|
80 ; FUNC-LABEL: {{^}}fneg_fabsf_v2f32:
|
150
|
81 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
|
|
82 ; R600: -PV
|
|
83 ; R600: |{{(PV|T[0-9])\.[XYZW]}}|
|
|
84 ; R600: -PV
|
|
85
|
|
86 ; FIXME: In this case two uses of the constant should be folded
|
236
|
87 ; SI: s_bitset1_b32 s{{[0-9]+}}, 31
|
|
88 ; SI: s_bitset1_b32 s{{[0-9]+}}, 31
|
252
|
89 define amdgpu_kernel void @fneg_fabsf_v2f32(ptr addrspace(1) %out, <2 x float> %in) {
|
150
|
90 %fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %in)
|
|
91 %fsub = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %fabs
|
252
|
92 store <2 x float> %fsub, ptr addrspace(1) %out
|
150
|
93 ret void
|
|
94 }
|
|
95
|
236
|
96 ; FUNC-LABEL: {{^}}fneg_fabsf_v4f32:
|
|
97 ; SI: s_bitset1_b32 s{{[0-9]+}}, 31
|
|
98 ; SI: s_bitset1_b32 s{{[0-9]+}}, 31
|
|
99 ; SI: s_bitset1_b32 s{{[0-9]+}}, 31
|
|
100 ; SI: s_bitset1_b32 s{{[0-9]+}}, 31
|
252
|
101 define amdgpu_kernel void @fneg_fabsf_v4f32(ptr addrspace(1) %out, <4 x float> %in) {
|
150
|
102 %fabs = call <4 x float> @llvm.fabs.v4f32(<4 x float> %in)
|
|
103 %fsub = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %fabs
|
252
|
104 store <4 x float> %fsub, ptr addrspace(1) %out
|
150
|
105 ret void
|
|
106 }
|
|
107
|
236
|
108 declare float @fabsf(float) readnone
|
150
|
109 declare float @llvm.fabs.f32(float) readnone
|
|
110 declare <2 x float> @llvm.fabs.v2f32(<2 x float>) readnone
|
|
111 declare <4 x float> @llvm.fabs.v4f32(<4 x float>) readnone
|