xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/llvm.round.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=amdgcn -mcpu=tonga < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}round_f32:
6*9880d681SAndroid Build Coastguard Worker; SI-DAG: s_load_dword [[SX:s[0-9]+]]
7*9880d681SAndroid Build Coastguard Worker; SI-DAG: s_mov_b32 [[K:s[0-9]+]], 0x7fffffff
8*9880d681SAndroid Build Coastguard Worker; SI-DAG: v_trunc_f32_e32 [[TRUNC:v[0-9]+]], [[SX]]
9*9880d681SAndroid Build Coastguard Worker; SI-DAG: v_sub_f32_e32 [[SUB:v[0-9]+]], [[SX]], [[TRUNC]]
10*9880d681SAndroid Build Coastguard Worker; SI-DAG: v_mov_b32_e32 [[VX:v[0-9]+]], [[SX]]
11*9880d681SAndroid Build Coastguard Worker; SI: v_bfi_b32 [[COPYSIGN:v[0-9]+]], [[K]], 1.0, [[VX]]
12*9880d681SAndroid Build Coastguard Worker; SI: v_cmp_le_f32_e64 vcc, 0.5, |[[SUB]]|
13*9880d681SAndroid Build Coastguard Worker; SI: v_cndmask_b32_e32 [[SEL:v[0-9]+]], 0, [[VX]]
14*9880d681SAndroid Build Coastguard Worker; SI: v_add_f32_e32 [[RESULT:v[0-9]+]], [[SEL]], [[TRUNC]]
15*9880d681SAndroid Build Coastguard Worker; SI: buffer_store_dword [[RESULT]]
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Worker; R600: TRUNC {{.*}}, [[ARG:KC[0-9]\[[0-9]+\]\.[XYZW]]]
18*9880d681SAndroid Build Coastguard Worker; R600-DAG: ADD  {{.*}},
19*9880d681SAndroid Build Coastguard Worker; R600-DAG: BFI_INT
20*9880d681SAndroid Build Coastguard Worker; R600-DAG: SETGE
21*9880d681SAndroid Build Coastguard Worker; R600-DAG: CNDE
22*9880d681SAndroid Build Coastguard Worker; R600-DAG: ADD
23*9880d681SAndroid Build Coastguard Workerdefine void @round_f32(float addrspace(1)* %out, float %x) #0 {
24*9880d681SAndroid Build Coastguard Worker  %result = call float @llvm.round.f32(float %x) #1
25*9880d681SAndroid Build Coastguard Worker  store float %result, float addrspace(1)* %out
26*9880d681SAndroid Build Coastguard Worker  ret void
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; The vector tests are really difficult to verify, since it can be hard to
30*9880d681SAndroid Build Coastguard Worker; predict how the scheduler will order the instructions.  We already have
31*9880d681SAndroid Build Coastguard Worker; a test for the scalar case, so the vector tests just check that the
32*9880d681SAndroid Build Coastguard Worker; compiler doesn't crash.
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}round_v2f32:
35*9880d681SAndroid Build Coastguard Worker; SI: s_endpgm
36*9880d681SAndroid Build Coastguard Worker; R600: CF_END
37*9880d681SAndroid Build Coastguard Workerdefine void @round_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %in) #0 {
38*9880d681SAndroid Build Coastguard Worker  %result = call <2 x float> @llvm.round.v2f32(<2 x float> %in) #1
39*9880d681SAndroid Build Coastguard Worker  store <2 x float> %result, <2 x float> addrspace(1)* %out
40*9880d681SAndroid Build Coastguard Worker  ret void
41*9880d681SAndroid Build Coastguard Worker}
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}round_v4f32:
44*9880d681SAndroid Build Coastguard Worker; SI: s_endpgm
45*9880d681SAndroid Build Coastguard Worker; R600: CF_END
46*9880d681SAndroid Build Coastguard Workerdefine void @round_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %in) #0 {
47*9880d681SAndroid Build Coastguard Worker  %result = call <4 x float> @llvm.round.v4f32(<4 x float> %in) #1
48*9880d681SAndroid Build Coastguard Worker  store <4 x float> %result, <4 x float> addrspace(1)* %out
49*9880d681SAndroid Build Coastguard Worker  ret void
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; FUNC-LABEL: {{^}}round_v8f32:
53*9880d681SAndroid Build Coastguard Worker; SI: s_endpgm
54*9880d681SAndroid Build Coastguard Worker; R600: CF_END
55*9880d681SAndroid Build Coastguard Workerdefine void @round_v8f32(<8 x float> addrspace(1)* %out, <8 x float> %in) #0 {
56*9880d681SAndroid Build Coastguard Worker  %result = call <8 x float> @llvm.round.v8f32(<8 x float> %in) #1
57*9880d681SAndroid Build Coastguard Worker  store <8 x float> %result, <8 x float> addrspace(1)* %out
58*9880d681SAndroid Build Coastguard Worker  ret void
59*9880d681SAndroid Build Coastguard Worker}
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.round.f32(float) #1
62*9880d681SAndroid Build Coastguard Workerdeclare <2 x float> @llvm.round.v2f32(<2 x float>) #1
63*9880d681SAndroid Build Coastguard Workerdeclare <4 x float> @llvm.round.v4f32(<4 x float>) #1
64*9880d681SAndroid Build Coastguard Workerdeclare <8 x float> @llvm.round.v8f32(<8 x float>) #1
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind }
67*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
68