mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-20 12:05:48 -04:00

Summary: RCP has the accuracy limit. If FDIV fpmath require high accuracy rcp may not meet the requirement. However, in DAG lowering, fpmath information gets lost, and thus we may generate either inaccurate rcp related computation or slow code for fdiv. In patch implements fdiv optimizations in the AMDGPUCodeGenPrepare, which could exactly know !fpmath. FastUnsafeRcpLegal: We determine whether it is legal to use rcp based on unsafe-fp-math, fast math flags, denormals and fpmath accuracy request. RCP Optimizations: 1/x -> rcp(x) when fast unsafe rcp is legal or fpmath >= 2.5ULP with denormals flushed. a/b -> a*rcp(b) when fast unsafe rcp is legal. Use fdiv.fast: a/b -> fdiv.fast(a, b) when RCP optimization is not performed and fpmath >= 2.5ULP with denormals flushed. 1/x -> fdiv.fast(1,x) when RCP optimization is not performed and fpmath >= 2.5ULP with denormals. Reviewers: arsenm Differential Revision: https://reviews.llvm.org/D71293
24 lines
808 B
LLVM
24 lines
808 B
LLVM
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck --check-prefix=GCN %s
|
|
|
|
; GCN-LABEL: {{^}}rcp_uint:
|
|
; GCN: v_rcp_iflag_f32_e32
|
|
define amdgpu_kernel void @rcp_uint(i32 addrspace(1)* %in, float addrspace(1)* %out) {
|
|
%load = load i32, i32 addrspace(1)* %in, align 4
|
|
%cvt = uitofp i32 %load to float
|
|
%div = fdiv float 1.000000e+00, %cvt, !fpmath !0
|
|
store float %div, float addrspace(1)* %out, align 4
|
|
ret void
|
|
}
|
|
|
|
; GCN-LABEL: {{^}}rcp_sint:
|
|
; GCN: v_rcp_iflag_f32_e32
|
|
define amdgpu_kernel void @rcp_sint(i32 addrspace(1)* %in, float addrspace(1)* %out) {
|
|
%load = load i32, i32 addrspace(1)* %in, align 4
|
|
%cvt = sitofp i32 %load to float
|
|
%div = fdiv float 1.000000e+00, %cvt, !fpmath !0
|
|
store float %div, float addrspace(1)* %out, align 4
|
|
ret void
|
|
}
|
|
|
|
!0 = !{float 2.500000e+00}
|