xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.rsq.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.amdgcn.rsq.f32(float) #0
5*9880d681SAndroid Build Coastguard Workerdeclare double @llvm.amdgcn.rsq.f64(double) #0
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_f32:
8*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_f32_e32 {{v[0-9]+}}, {{s[0-9]+}}
9*9880d681SAndroid Build Coastguard Workerdefine void @rsq_f32(float addrspace(1)* %out, float %src) #1 {
10*9880d681SAndroid Build Coastguard Worker  %rsq = call float @llvm.amdgcn.rsq.f32(float %src) #0
11*9880d681SAndroid Build Coastguard Worker  store float %rsq, float addrspace(1)* %out, align 4
12*9880d681SAndroid Build Coastguard Worker  ret void
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker; TODO: Really these should be constant folded
16*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_f32_constant_4.0
17*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_f32_e32 {{v[0-9]+}}, 4.0
18*9880d681SAndroid Build Coastguard Workerdefine void @rsq_f32_constant_4.0(float addrspace(1)* %out) #1 {
19*9880d681SAndroid Build Coastguard Worker  %rsq = call float @llvm.amdgcn.rsq.f32(float 4.0) #0
20*9880d681SAndroid Build Coastguard Worker  store float %rsq, float addrspace(1)* %out, align 4
21*9880d681SAndroid Build Coastguard Worker  ret void
22*9880d681SAndroid Build Coastguard Worker}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_f32_constant_100.0
25*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_f32_e32 {{v[0-9]+}}, 0x42c80000
26*9880d681SAndroid Build Coastguard Workerdefine void @rsq_f32_constant_100.0(float addrspace(1)* %out) #1 {
27*9880d681SAndroid Build Coastguard Worker  %rsq = call float @llvm.amdgcn.rsq.f32(float 100.0) #0
28*9880d681SAndroid Build Coastguard Worker  store float %rsq, float addrspace(1)* %out, align 4
29*9880d681SAndroid Build Coastguard Worker  ret void
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_f64:
33*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_f64_e32 {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}
34*9880d681SAndroid Build Coastguard Workerdefine void @rsq_f64(double addrspace(1)* %out, double %src) #1 {
35*9880d681SAndroid Build Coastguard Worker  %rsq = call double @llvm.amdgcn.rsq.f64(double %src) #0
36*9880d681SAndroid Build Coastguard Worker  store double %rsq, double addrspace(1)* %out, align 4
37*9880d681SAndroid Build Coastguard Worker  ret void
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker; TODO: Really these should be constant folded
41*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_f64_constant_4.0
42*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_f64_e32 {{v\[[0-9]+:[0-9]+\]}}, 4.0
43*9880d681SAndroid Build Coastguard Workerdefine void @rsq_f64_constant_4.0(double addrspace(1)* %out) #1 {
44*9880d681SAndroid Build Coastguard Worker  %rsq = call double @llvm.amdgcn.rsq.f64(double 4.0) #0
45*9880d681SAndroid Build Coastguard Worker  store double %rsq, double addrspace(1)* %out, align 4
46*9880d681SAndroid Build Coastguard Worker  ret void
47*9880d681SAndroid Build Coastguard Worker}
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_f64_constant_100.0
50*9880d681SAndroid Build Coastguard Worker; SI-DAG: s_mov_b32 s{{[0-9]+}}, 0x40590000
51*9880d681SAndroid Build Coastguard Worker; SI-DAG: s_mov_b32 s{{[0-9]+}}, 0{{$}}
52*9880d681SAndroid Build Coastguard Worker; SI: v_rsq_f64_e32 {{v\[[0-9]+:[0-9]+\]}}, {{s\[[0-9]+:[0-9]+\]}}
53*9880d681SAndroid Build Coastguard Workerdefine void @rsq_f64_constant_100.0(double addrspace(1)* %out) #1 {
54*9880d681SAndroid Build Coastguard Worker  %rsq = call double @llvm.amdgcn.rsq.f64(double 100.0) #0
55*9880d681SAndroid Build Coastguard Worker  store double %rsq, double addrspace(1)* %out, align 4
56*9880d681SAndroid Build Coastguard Worker  ret void
57*9880d681SAndroid Build Coastguard Worker}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}rsq_undef_f32:
60*9880d681SAndroid Build Coastguard Worker; SI-NOT: v_rsq_f32
61*9880d681SAndroid Build Coastguard Workerdefine void @rsq_undef_f32(float addrspace(1)* %out) #1 {
62*9880d681SAndroid Build Coastguard Worker  %rsq = call float @llvm.amdgcn.rsq.f32(float undef)
63*9880d681SAndroid Build Coastguard Worker  store float %rsq, float addrspace(1)* %out, align 4
64*9880d681SAndroid Build Coastguard Worker  ret void
65*9880d681SAndroid Build Coastguard Worker}
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind readnone }
68*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind }
69