blob: 7e8f8ff172e8fcc2b8e3c723f90a2ca9802f1ee7 [file] [log] [blame]
Matt Arsenaultbbb47da2016-09-08 17:19:29 +00001; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Matt Arsenault7aad8fd2017-01-24 22:02:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Matt Arsenaultb0055482015-01-21 18:18:25 +00003; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
Tom Stellard4d566b22013-11-27 21:23:20 +00004
Matt Arsenaultb0055482015-01-21 18:18:25 +00005; FUNC-LABEL: {{^}}round_f32:
6; SI-DAG: s_load_dword [[SX:s[0-9]+]]
Matt Arsenault663ab8c2016-11-01 23:14:20 +00007; SI-DAG: s_brev_b32 [[K:s[0-9]+]], -2{{$}}
Tom Stellardcb6ba622016-04-30 00:23:06 +00008; SI-DAG: v_trunc_f32_e32 [[TRUNC:v[0-9]+]], [[SX]]
9; SI-DAG: v_sub_f32_e32 [[SUB:v[0-9]+]], [[SX]], [[TRUNC]]
10; SI-DAG: v_mov_b32_e32 [[VX:v[0-9]+]], [[SX]]
Tom Stellard83f0bce2015-01-29 16:55:25 +000011; SI: v_bfi_b32 [[COPYSIGN:v[0-9]+]], [[K]], 1.0, [[VX]]
Matt Arsenaultbbb47da2016-09-08 17:19:29 +000012; SI: v_cmp_ge_f32_e64 vcc, |[[SUB]]|, 0.5
Tom Stellarde48fe2a2015-07-14 14:15:03 +000013; SI: v_cndmask_b32_e32 [[SEL:v[0-9]+]], 0, [[VX]]
Matt Arsenaultb0055482015-01-21 18:18:25 +000014; SI: v_add_f32_e32 [[RESULT:v[0-9]+]], [[SEL]], [[TRUNC]]
15; SI: buffer_store_dword [[RESULT]]
16
17; R600: TRUNC {{.*}}, [[ARG:KC[0-9]\[[0-9]+\]\.[XYZW]]]
18; R600-DAG: ADD {{.*}},
19; R600-DAG: BFI_INT
20; R600-DAG: SETGE
21; R600-DAG: CNDE
22; R600-DAG: ADD
23define void @round_f32(float addrspace(1)* %out, float %x) #0 {
24 %result = call float @llvm.round.f32(float %x) #1
25 store float %result, float addrspace(1)* %out
Tom Stellard4d566b22013-11-27 21:23:20 +000026 ret void
27}
28
29; The vector tests are really difficult to verify, since it can be hard to
30; predict how the scheduler will order the instructions. We already have
31; a test for the scalar case, so the vector tests just check that the
32; compiler doesn't crash.
33
Matt Arsenaultb0055482015-01-21 18:18:25 +000034; FUNC-LABEL: {{^}}round_v2f32:
35; SI: s_endpgm
Tom Stellard4d566b22013-11-27 21:23:20 +000036; R600: CF_END
Matt Arsenaultb0055482015-01-21 18:18:25 +000037define void @round_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %in) #0 {
38 %result = call <2 x float> @llvm.round.v2f32(<2 x float> %in) #1
39 store <2 x float> %result, <2 x float> addrspace(1)* %out
Tom Stellard4d566b22013-11-27 21:23:20 +000040 ret void
41}
42
Matt Arsenaultb0055482015-01-21 18:18:25 +000043; FUNC-LABEL: {{^}}round_v4f32:
44; SI: s_endpgm
Tom Stellard4d566b22013-11-27 21:23:20 +000045; R600: CF_END
Matt Arsenaultb0055482015-01-21 18:18:25 +000046define void @round_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %in) #0 {
47 %result = call <4 x float> @llvm.round.v4f32(<4 x float> %in) #1
48 store <4 x float> %result, <4 x float> addrspace(1)* %out
Tom Stellard4d566b22013-11-27 21:23:20 +000049 ret void
50}
51
Matt Arsenaultb0055482015-01-21 18:18:25 +000052; FUNC-LABEL: {{^}}round_v8f32:
53; SI: s_endpgm
54; R600: CF_END
55define void @round_v8f32(<8 x float> addrspace(1)* %out, <8 x float> %in) #0 {
56 %result = call <8 x float> @llvm.round.v8f32(<8 x float> %in) #1
57 store <8 x float> %result, <8 x float> addrspace(1)* %out
58 ret void
59}
60
61declare float @llvm.round.f32(float) #1
62declare <2 x float> @llvm.round.v2f32(<2 x float>) #1
63declare <4 x float> @llvm.round.v4f32(<4 x float>) #1
64declare <8 x float> @llvm.round.v8f32(<8 x float>) #1
65
66attributes #0 = { nounwind }
67attributes #1 = { nounwind readnone }