1; RUN: llc -march=amdgcn -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2
3; FUNC-LABEL: {{^}}round_f64:
4; SI: s_endpgm
5define void @round_f64(double addrspace(1)* %out, double %x) #0 {
6  %result = call double @llvm.round.f64(double %x) #1
7  store double %result, double addrspace(1)* %out
8  ret void
9}
10
11; This is a pretty large function, so just test a few of the
12; instructions that are necessary.
13
14; FUNC-LABEL: {{^}}v_round_f64:
15; SI: buffer_load_dwordx2
16; SI: v_bfe_u32 [[EXP:v[0-9]+]], v{{[0-9]+}}, 20, 11
17
18; SI-DAG: v_not_b32_e32
19; SI-DAG: v_not_b32_e32
20
21; SI-DAG: v_cmp_eq_i32
22
23; SI-DAG: s_mov_b32 [[BFIMASK:s[0-9]+]], 0x7fffffff
24; SI-DAG: v_cmp_gt_i32_e64
25; SI-DAG: v_bfi_b32 [[COPYSIGN:v[0-9]+]], [[BFIMASK]]
26
27; SI-DAG: v_cmp_gt_i32_e64
28
29
30; SI: buffer_store_dwordx2
31; SI: s_endpgm
32define void @v_round_f64(double addrspace(1)* %out, double addrspace(1)* %in) #0 {
33  %tid = call i32 @llvm.r600.read.tidig.x() #1
34  %gep = getelementptr double, double addrspace(1)* %in, i32 %tid
35  %out.gep = getelementptr double, double addrspace(1)* %out, i32 %tid
36  %x = load double, double addrspace(1)* %gep
37  %result = call double @llvm.round.f64(double %x) #1
38  store double %result, double addrspace(1)* %out.gep
39  ret void
40}
41
42; FUNC-LABEL: {{^}}round_v2f64:
43; SI: s_endpgm
44define void @round_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %in) #0 {
45  %result = call <2 x double> @llvm.round.v2f64(<2 x double> %in) #1
46  store <2 x double> %result, <2 x double> addrspace(1)* %out
47  ret void
48}
49
50; FUNC-LABEL: {{^}}round_v4f64:
51; SI: s_endpgm
52define void @round_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %in) #0 {
53  %result = call <4 x double> @llvm.round.v4f64(<4 x double> %in) #1
54  store <4 x double> %result, <4 x double> addrspace(1)* %out
55  ret void
56}
57
58; FUNC-LABEL: {{^}}round_v8f64:
59; SI: s_endpgm
60define void @round_v8f64(<8 x double> addrspace(1)* %out, <8 x double> %in) #0 {
61  %result = call <8 x double> @llvm.round.v8f64(<8 x double> %in) #1
62  store <8 x double> %result, <8 x double> addrspace(1)* %out
63  ret void
64}
65
66declare i32 @llvm.r600.read.tidig.x() #1
67
68declare double @llvm.round.f64(double) #1
69declare <2 x double> @llvm.round.v2f64(<2 x double>) #1
70declare <4 x double> @llvm.round.v4f64(<4 x double>) #1
71declare <8 x double> @llvm.round.v8f64(<8 x double>) #1
72
73attributes #0 = { nounwind }
74attributes #1 = { nounwind readnone }
75