annotate llvm/test/CodeGen/AMDGPU/fneg.ll @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
anatofuz
parents:
diff changeset
2 ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefix=VI -check-prefix=GCN -check-prefix=FUNC %s
anatofuz
parents:
diff changeset
3 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -enable-var-scope -check-prefix=R600 -check-prefix=FUNC %s
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 ; FUNC-LABEL: {{^}}s_fneg_f32:
anatofuz
parents:
diff changeset
6 ; R600: -PV
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 ; GCN: s_load_dword [[VAL:s[0-9]+]]
anatofuz
parents:
diff changeset
9 ; GCN: s_xor_b32 [[NEG_VAL:s[0-9]+]], [[VAL]], 0x80000000
anatofuz
parents:
diff changeset
10 ; GCN: v_mov_b32_e32 v{{[0-9]+}}, [[NEG_VAL]]
anatofuz
parents:
diff changeset
11 define amdgpu_kernel void @s_fneg_f32(float addrspace(1)* %out, float %in) {
anatofuz
parents:
diff changeset
12 %fneg = fsub float -0.000000e+00, %in
anatofuz
parents:
diff changeset
13 store float %fneg, float addrspace(1)* %out
anatofuz
parents:
diff changeset
14 ret void
anatofuz
parents:
diff changeset
15 }
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 ; FUNC-LABEL: {{^}}s_fneg_v2f32:
anatofuz
parents:
diff changeset
18 ; R600: -PV
anatofuz
parents:
diff changeset
19 ; R600: -PV
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 ; GCN: s_brev_b32 [[SIGNBIT:s[0-9]+]], 1
anatofuz
parents:
diff changeset
22 ; GCN: s_xor_b32
anatofuz
parents:
diff changeset
23 ; GCN: s_xor_b32
anatofuz
parents:
diff changeset
24 define amdgpu_kernel void @s_fneg_v2f32(<2 x float> addrspace(1)* nocapture %out, <2 x float> %in) {
anatofuz
parents:
diff changeset
25 %fneg = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, %in
anatofuz
parents:
diff changeset
26 store <2 x float> %fneg, <2 x float> addrspace(1)* %out
anatofuz
parents:
diff changeset
27 ret void
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 ; FUNC-LABEL: {{^}}s_fneg_v4f32:
anatofuz
parents:
diff changeset
31 ; R600: -PV
anatofuz
parents:
diff changeset
32 ; R600: -T
anatofuz
parents:
diff changeset
33 ; R600: -PV
anatofuz
parents:
diff changeset
34 ; R600: -PV
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 ; GCN: s_xor_b32
anatofuz
parents:
diff changeset
37 ; GCN: s_xor_b32
anatofuz
parents:
diff changeset
38 ; GCN: s_xor_b32
anatofuz
parents:
diff changeset
39 ; GCN: s_xor_b32
anatofuz
parents:
diff changeset
40 define amdgpu_kernel void @s_fneg_v4f32(<4 x float> addrspace(1)* nocapture %out, <4 x float> %in) {
anatofuz
parents:
diff changeset
41 %fneg = fsub <4 x float> <float -0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00>, %in
anatofuz
parents:
diff changeset
42 store <4 x float> %fneg, <4 x float> addrspace(1)* %out
anatofuz
parents:
diff changeset
43 ret void
anatofuz
parents:
diff changeset
44 }
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 ; DAGCombiner will transform:
anatofuz
parents:
diff changeset
47 ; (fneg (f32 bitcast (i32 a))) => (f32 bitcast (xor (i32 a), 0x80000000))
anatofuz
parents:
diff changeset
48 ; unless the target returns true for isNegFree()
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 ; FUNC-LABEL: {{^}}fsub0_f32:
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 ; GCN: v_sub_f32_e64 v{{[0-9]}}, 0, s{{[0-9]+$}}
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 ; R600-NOT: XOR
anatofuz
parents:
diff changeset
55 ; R600: -KC0[2].Z
anatofuz
parents:
diff changeset
56 define amdgpu_kernel void @fsub0_f32(float addrspace(1)* %out, i32 %in) {
anatofuz
parents:
diff changeset
57 %bc = bitcast i32 %in to float
anatofuz
parents:
diff changeset
58 %fsub = fsub float 0.0, %bc
anatofuz
parents:
diff changeset
59 store float %fsub, float addrspace(1)* %out
anatofuz
parents:
diff changeset
60 ret void
anatofuz
parents:
diff changeset
61 }
anatofuz
parents:
diff changeset
62 ; FUNC-LABEL: {{^}}fneg_free_f32:
anatofuz
parents:
diff changeset
63 ; SI: s_load_dword [[NEG_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0xb
anatofuz
parents:
diff changeset
64 ; VI: s_load_dword [[NEG_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0x2c
anatofuz
parents:
diff changeset
65
anatofuz
parents:
diff changeset
66 ; GCN: s_xor_b32 [[RES:s[0-9]+]], [[NEG_VALUE]], 0x80000000
anatofuz
parents:
diff changeset
67 ; GCN: v_mov_b32_e32 [[V_RES:v[0-9]+]], [[RES]]
anatofuz
parents:
diff changeset
68 ; GCN: buffer_store_dword [[V_RES]]
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 ; R600-NOT: XOR
anatofuz
parents:
diff changeset
71 ; R600: -PV.W
anatofuz
parents:
diff changeset
72 define amdgpu_kernel void @fneg_free_f32(float addrspace(1)* %out, i32 %in) {
anatofuz
parents:
diff changeset
73 %bc = bitcast i32 %in to float
anatofuz
parents:
diff changeset
74 %fsub = fsub float -0.0, %bc
anatofuz
parents:
diff changeset
75 store float %fsub, float addrspace(1)* %out
anatofuz
parents:
diff changeset
76 ret void
anatofuz
parents:
diff changeset
77 }
anatofuz
parents:
diff changeset
78
anatofuz
parents:
diff changeset
79 ; FUNC-LABEL: {{^}}fneg_fold_f32:
anatofuz
parents:
diff changeset
80 ; SI: s_load_dword [[NEG_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0xb
anatofuz
parents:
diff changeset
81 ; VI: s_load_dword [[NEG_VALUE:s[0-9]+]], s[{{[0-9]+:[0-9]+}}], 0x2c
anatofuz
parents:
diff changeset
82 ; GCN-NOT: xor
anatofuz
parents:
diff changeset
83 ; GCN: v_mul_f32_e64 v{{[0-9]+}}, -[[NEG_VALUE]], [[NEG_VALUE]]
anatofuz
parents:
diff changeset
84 define amdgpu_kernel void @fneg_fold_f32(float addrspace(1)* %out, float %in) {
anatofuz
parents:
diff changeset
85 %fsub = fsub float -0.0, %in
anatofuz
parents:
diff changeset
86 %fmul = fmul float %fsub, %in
anatofuz
parents:
diff changeset
87 store float %fmul, float addrspace(1)* %out
anatofuz
parents:
diff changeset
88 ret void
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 ; Make sure we turn some integer operations back into fabs
anatofuz
parents:
diff changeset
92 ; FUNC-LABEL: {{^}}bitpreserve_fneg_f32:
anatofuz
parents:
diff changeset
93 ; GCN: v_mul_f32_e64 v{{[0-9]+}}, s{{[0-9]+}}, -4.0
anatofuz
parents:
diff changeset
94 define amdgpu_kernel void @bitpreserve_fneg_f32(float addrspace(1)* %out, float %in) {
anatofuz
parents:
diff changeset
95 %in.bc = bitcast float %in to i32
anatofuz
parents:
diff changeset
96 %int.abs = xor i32 %in.bc, 2147483648
anatofuz
parents:
diff changeset
97 %bc = bitcast i32 %int.abs to float
anatofuz
parents:
diff changeset
98 %fadd = fmul float %bc, 4.0
anatofuz
parents:
diff changeset
99 store float %fadd, float addrspace(1)* %out
anatofuz
parents:
diff changeset
100 ret void
anatofuz
parents:
diff changeset
101 }