Matt Arsenault | bbb47da | 2016-09-08 17:19:29 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s |
Matt Arsenault | 7aad8fd | 2017-01-24 22:02:15 +0000 | [diff] [blame] | 2 | ; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 3 | ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s |
Tom Stellard | 4d566b2 | 2013-11-27 21:23:20 +0000 | [diff] [blame] | 4 | |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 5 | ; FUNC-LABEL: {{^}}round_f32: |
| 6 | ; SI-DAG: s_load_dword [[SX:s[0-9]+]] |
Matt Arsenault | 663ab8c | 2016-11-01 23:14:20 +0000 | [diff] [blame] | 7 | ; SI-DAG: s_brev_b32 [[K:s[0-9]+]], -2{{$}} |
Tom Stellard | cb6ba62 | 2016-04-30 00:23:06 +0000 | [diff] [blame] | 8 | ; 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 Stellard | 83f0bce | 2015-01-29 16:55:25 +0000 | [diff] [blame] | 11 | ; SI: v_bfi_b32 [[COPYSIGN:v[0-9]+]], [[K]], 1.0, [[VX]] |
Matt Arsenault | bbb47da | 2016-09-08 17:19:29 +0000 | [diff] [blame] | 12 | ; SI: v_cmp_ge_f32_e64 vcc, |[[SUB]]|, 0.5 |
Tom Stellard | e48fe2a | 2015-07-14 14:15:03 +0000 | [diff] [blame] | 13 | ; SI: v_cndmask_b32_e32 [[SEL:v[0-9]+]], 0, [[VX]] |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 14 | ; 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 |
| 23 | define 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 Stellard | 4d566b2 | 2013-11-27 21:23:20 +0000 | [diff] [blame] | 26 | 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 Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 34 | ; FUNC-LABEL: {{^}}round_v2f32: |
| 35 | ; SI: s_endpgm |
Tom Stellard | 4d566b2 | 2013-11-27 21:23:20 +0000 | [diff] [blame] | 36 | ; R600: CF_END |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 37 | define 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 Stellard | 4d566b2 | 2013-11-27 21:23:20 +0000 | [diff] [blame] | 40 | ret void |
| 41 | } |
| 42 | |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 43 | ; FUNC-LABEL: {{^}}round_v4f32: |
| 44 | ; SI: s_endpgm |
Tom Stellard | 4d566b2 | 2013-11-27 21:23:20 +0000 | [diff] [blame] | 45 | ; R600: CF_END |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 46 | define 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 Stellard | 4d566b2 | 2013-11-27 21:23:20 +0000 | [diff] [blame] | 49 | ret void |
| 50 | } |
| 51 | |
Matt Arsenault | b005548 | 2015-01-21 18:18:25 +0000 | [diff] [blame] | 52 | ; FUNC-LABEL: {{^}}round_v8f32: |
| 53 | ; SI: s_endpgm |
| 54 | ; R600: CF_END |
| 55 | define 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 | |
| 61 | declare float @llvm.round.f32(float) #1 |
| 62 | declare <2 x float> @llvm.round.v2f32(<2 x float>) #1 |
| 63 | declare <4 x float> @llvm.round.v4f32(<4 x float>) #1 |
| 64 | declare <8 x float> @llvm.round.v8f32(<8 x float>) #1 |
| 65 | |
| 66 | attributes #0 = { nounwind } |
| 67 | attributes #1 = { nounwind readnone } |