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 6 7declare float @llvm.fabs.f32(float) #0 8declare float @llvm.floor.f32(float) #0 9 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]] 13 14; GCN-UNSAFE: v_fract_f32_e32 [[RESULT:v[0-9]+]], [[INPUT:v[0-9]+]] 15 16; GCN: buffer_store_dword [[RESULT]] 17define 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 22 ret void 23} 24 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]] 28 29; GCN-UNSAFE: v_fract_f32_e64 [[RESULT:v[0-9]+]], -[[INPUT:v[0-9]+]] 30 31; GCN: buffer_store_dword [[RESULT]] 32define 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 38 ret void 39} 40 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]] 44 45; GCN-UNSAFE: v_fract_f32_e64 [[RESULT:v[0-9]+]], -|[[INPUT:v[0-9]+]]| 46 47; GCN: buffer_store_dword [[RESULT]] 48define 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 55 ret void 56} 57 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]+]] 61 62; GCN-UNSAFE: buffer_store_dword [[FLOOR]] 63; GCN-UNSAFE: buffer_store_dword [[FRACT]] 64define 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 70 ret void 71} 72 73attributes #0 = { nounwind readnone } 74attributes #1 = { nounwind } 75