1 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN-SAFE -check-prefix=GCN -check-prefix=SI %s
2 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=bonaire -verify-machineinstrs < %s | FileCheck -check-prefix=GCN-SAFE -check-prefix=GCN -check-prefix=CI %s
3 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=GCN-SAFE -check-prefix=GCN -check-prefix=FUNC %s
4 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -verify-machineinstrs -enable-unsafe-fp-math < %s | FileCheck -check-prefix=GCN-UNSAFE -check-prefix=GCN %s
5 ; RUN: llc -amdgpu-scalarize-global-loads=false -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs -enable-unsafe-fp-math < %s | FileCheck -check-prefix=GCN-UNSAFE -check-prefix=GCN %s
7 declare float @llvm.fabs.f32(float) #0
8 declare float @llvm.floor.f32(float) #0
10 ; GCN-LABEL: {{^}}fract_f32:
11 ; GCN-SAFE: v_floor_f32_e32 [[FLR:v[0-9]+]], [[INPUT:v[0-9]+]]
12 ; GCN-SAFE: v_sub_f32_e32 [[RESULT:v[0-9]+]], [[INPUT]], [[FLR]]
14 ; GCN-UNSAFE: v_fract_f32_e32 [[RESULT:v[0-9]+]], [[INPUT:v[0-9]+]]
16 ; GCN: buffer_store_dword [[RESULT]]
17 define amdgpu_kernel void @fract_f32(float addrspace(1)* %out, float addrspace(1)* %src) #1 {
18 %x = load float, float addrspace(1)* %src
19 %floor.x = call float @llvm.floor.f32(float %x)
20 %fract = fsub float %x, %floor.x
21 store float %fract, float addrspace(1)* %out
25 ; GCN-LABEL: {{^}}fract_f32_neg:
26 ; GCN-SAFE: v_floor_f32_e64 [[FLR:v[0-9]+]], -[[INPUT:v[0-9]+]]
27 ; GCN-SAFE: v_sub_f32_e64 [[RESULT:v[0-9]+]], -[[INPUT]], [[FLR]]
29 ; GCN-UNSAFE: v_fract_f32_e64 [[RESULT:v[0-9]+]], -[[INPUT:v[0-9]+]]
31 ; GCN: buffer_store_dword [[RESULT]]
32 define amdgpu_kernel void @fract_f32_neg(float addrspace(1)* %out, float addrspace(1)* %src) #1 {
33 %x = load float, float addrspace(1)* %src
34 %x.neg = fsub float -0.0, %x
35 %floor.x.neg = call float @llvm.floor.f32(float %x.neg)
36 %fract = fsub float %x.neg, %floor.x.neg
37 store float %fract, float addrspace(1)* %out
41 ; GCN-LABEL: {{^}}fract_f32_neg_abs:
42 ; GCN-SAFE: v_floor_f32_e64 [[FLR:v[0-9]+]], -|[[INPUT:v[0-9]+]]|
43 ; GCN-SAFE: v_sub_f32_e64 [[RESULT:v[0-9]+]], -|[[INPUT]]|, [[FLR]]
45 ; GCN-UNSAFE: v_fract_f32_e64 [[RESULT:v[0-9]+]], -|[[INPUT:v[0-9]+]]|
47 ; GCN: buffer_store_dword [[RESULT]]
48 define amdgpu_kernel void @fract_f32_neg_abs(float addrspace(1)* %out, float addrspace(1)* %src) #1 {
49 %x = load float, float addrspace(1)* %src
50 %abs.x = call float @llvm.fabs.f32(float %x)
51 %neg.abs.x = fsub float -0.0, %abs.x
52 %floor.neg.abs.x = call float @llvm.floor.f32(float %neg.abs.x)
53 %fract = fsub float %neg.abs.x, %floor.neg.abs.x
54 store float %fract, float addrspace(1)* %out
58 ; GCN-LABEL: {{^}}multi_use_floor_fract_f32:
59 ; GCN-UNSAFE-DAG: v_floor_f32_e32 [[FLOOR:v[0-9]+]], [[INPUT:v[0-9]+]]
60 ; GCN-UNSAFE-DAG: v_fract_f32_e32 [[FRACT:v[0-9]+]], [[INPUT:v[0-9]+]]
62 ; GCN-UNSAFE: buffer_store_dword [[FLOOR]]
63 ; GCN-UNSAFE: buffer_store_dword [[FRACT]]
64 define amdgpu_kernel void @multi_use_floor_fract_f32(float addrspace(1)* %out, float addrspace(1)* %src) #1 {
65 %x = load float, float addrspace(1)* %src
66 %floor.x = call float @llvm.floor.f32(float %x)
67 %fract = fsub float %x, %floor.x
68 store volatile float %floor.x, float addrspace(1)* %out
69 store volatile float %fract, float addrspace(1)* %out
73 attributes #0 = { nounwind readnone }
74 attributes #1 = { nounwind }