1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s  | FileCheck -check-prefix=GCN %s
3
4declare float @llvm.fabs.f32(float) #0
5declare double @llvm.fabs.f64(double) #0
6declare i32 @llvm.amdgcn.frexp.exp.i32.f32(float) #0
7declare i32 @llvm.amdgcn.frexp.exp.i32.f64(double) #0
8
9; GCN-LABEL: {{^}}s_test_frexp_exp_f32:
10; GCN: v_frexp_exp_i32_f32_e32 {{v[0-9]+}}, {{s[0-9]+}}
11define amdgpu_kernel void @s_test_frexp_exp_f32(i32 addrspace(1)* %out, float %src) #1 {
12  %frexp.exp = call i32 @llvm.amdgcn.frexp.exp.i32.f32(float %src)
13  store i32 %frexp.exp, i32 addrspace(1)* %out
14  ret void
15}
16
17; GCN-LABEL: {{^}}s_test_fabs_frexp_exp_f32:
18; GCN: v_frexp_exp_i32_f32_e64 {{v[0-9]+}}, |{{s[0-9]+}}|
19define amdgpu_kernel void @s_test_fabs_frexp_exp_f32(i32 addrspace(1)* %out, float %src) #1 {
20  %fabs.src = call float @llvm.fabs.f32(float %src)
21  %frexp.exp = call i32 @llvm.amdgcn.frexp.exp.i32.f32(float %fabs.src)
22  store i32 %frexp.exp, i32 addrspace(1)* %out
23  ret void
24}
25
26; GCN-LABEL: {{^}}s_test_fneg_fabs_frexp_exp_f32:
27; GCN: v_frexp_exp_i32_f32_e64 {{v[0-9]+}}, -|{{s[0-9]+}}|
28define amdgpu_kernel void @s_test_fneg_fabs_frexp_exp_f32(i32 addrspace(1)* %out, float %src) #1 {
29  %fabs.src = call float @llvm.fabs.f32(float %src)
30  %fneg.fabs.src = fsub float -0.0, %fabs.src
31  %frexp.exp = call i32 @llvm.amdgcn.frexp.exp.i32.f32(float %fneg.fabs.src)
32  store i32 %frexp.exp, i32 addrspace(1)* %out
33  ret void
34}
35
36; GCN-LABEL: {{^}}s_test_frexp_exp_f64:
37; GCN: v_frexp_exp_i32_f64_e32 {{v[0-9]+}}, {{s\[[0-9]+:[0-9]+\]}}
38define amdgpu_kernel void @s_test_frexp_exp_f64(i32 addrspace(1)* %out, double %src) #1 {
39  %frexp.exp = call i32 @llvm.amdgcn.frexp.exp.i32.f64(double %src)
40  store i32 %frexp.exp, i32 addrspace(1)* %out
41  ret void
42}
43
44; GCN-LABEL: {{^}}s_test_fabs_frexp_exp_f64:
45; GCN: v_frexp_exp_i32_f64_e64 {{v[0-9]+}}, |{{s\[[0-9]+:[0-9]+\]}}|
46define amdgpu_kernel void @s_test_fabs_frexp_exp_f64(i32 addrspace(1)* %out, double %src) #1 {
47  %fabs.src = call double @llvm.fabs.f64(double %src)
48  %frexp.exp = call i32 @llvm.amdgcn.frexp.exp.i32.f64(double %fabs.src)
49  store i32 %frexp.exp, i32 addrspace(1)* %out
50  ret void
51}
52
53; GCN-LABEL: {{^}}s_test_fneg_fabs_frexp_exp_f64:
54; GCN: v_frexp_exp_i32_f64_e64 {{v[0-9]+}}, -|{{s\[[0-9]+:[0-9]+\]}}|
55define amdgpu_kernel void @s_test_fneg_fabs_frexp_exp_f64(i32 addrspace(1)* %out, double %src) #1 {
56  %fabs.src = call double @llvm.fabs.f64(double %src)
57  %fneg.fabs.src = fsub double -0.0, %fabs.src
58  %frexp.exp = call i32 @llvm.amdgcn.frexp.exp.i32.f64(double %fneg.fabs.src)
59  store i32 %frexp.exp, i32 addrspace(1)* %out
60  ret void
61}
62
63attributes #0 = { nounwind readnone }
64attributes #1 = { nounwind }
65