mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[AMDGPU] Fix regression in AMDGPULibCalls allowing native for doubles
Under -cl-fast-relaxed-math we could use native_sqrt, but f64 was allowed to produce HSAIL's nsqrt instruction. HSAIL is not here and we stick with non-existing native_sqrt(double) as a result. Add check for f64 to not return native functions and also remove handling of f64 case for fold_sqrt. Differential Revision: https://reviews.llvm.org/D37223 llvm-svn: 311900
This commit is contained in:
parent
5f48b3a89c
commit
22de6c878a
@ -1170,6 +1170,8 @@ bool AMDGPULibCalls::fold_fma_mad(CallInst *CI, IRBuilder<> &B,
|
|||||||
|
|
||||||
// Get a scalar native builtin signle argument FP function
|
// Get a scalar native builtin signle argument FP function
|
||||||
Constant* AMDGPULibCalls::getNativeFunction(Module* M, const FuncInfo& FInfo) {
|
Constant* AMDGPULibCalls::getNativeFunction(Module* M, const FuncInfo& FInfo) {
|
||||||
|
if (getArgType(FInfo) == AMDGPULibFunc::F64 || !HasNative(FInfo.getId()))
|
||||||
|
return nullptr;
|
||||||
FuncInfo nf = FInfo;
|
FuncInfo nf = FInfo;
|
||||||
nf.setPrefix(AMDGPULibFunc::NATIVE);
|
nf.setPrefix(AMDGPULibFunc::NATIVE);
|
||||||
return getFunction(M, nf);
|
return getFunction(M, nf);
|
||||||
@ -1178,9 +1180,7 @@ Constant* AMDGPULibCalls::getNativeFunction(Module* M, const FuncInfo& FInfo) {
|
|||||||
// fold sqrt -> native_sqrt (x)
|
// fold sqrt -> native_sqrt (x)
|
||||||
bool AMDGPULibCalls::fold_sqrt(CallInst *CI, IRBuilder<> &B,
|
bool AMDGPULibCalls::fold_sqrt(CallInst *CI, IRBuilder<> &B,
|
||||||
const FuncInfo &FInfo) {
|
const FuncInfo &FInfo) {
|
||||||
if ((getArgType(FInfo) == AMDGPULibFunc::F32 ||
|
if (getArgType(FInfo) == AMDGPULibFunc::F32 && (getVecSize(FInfo) == 1) &&
|
||||||
getArgType(FInfo) == AMDGPULibFunc::F64) &&
|
|
||||||
(getVecSize(FInfo) == 1) &&
|
|
||||||
(FInfo.getPrefix() != AMDGPULibFunc::NATIVE)) {
|
(FInfo.getPrefix() != AMDGPULibFunc::NATIVE)) {
|
||||||
if (Constant *FPExpr = getNativeFunction(
|
if (Constant *FPExpr = getNativeFunction(
|
||||||
CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) {
|
CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) {
|
||||||
|
@ -641,7 +641,18 @@ entry:
|
|||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; GCN-LABEL: {{^}}define amdgpu_kernel void @test_dont_use_native_sqrt_fast_f64
|
||||||
|
; GCN: tail call fast double @_Z4sqrtd(double %tmp)
|
||||||
|
define amdgpu_kernel void @test_dont_use_native_sqrt_fast_f64(double addrspace(1)* nocapture %a) {
|
||||||
|
entry:
|
||||||
|
%tmp = load double, double addrspace(1)* %a, align 8
|
||||||
|
%call = tail call fast double @_Z4sqrtd(double %tmp)
|
||||||
|
store double %call, double addrspace(1)* %a, align 8
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
declare float @_Z4sqrtf(float)
|
declare float @_Z4sqrtf(float)
|
||||||
|
declare double @_Z4sqrtd(double)
|
||||||
|
|
||||||
; GCN-LABEL: {{^}}define amdgpu_kernel void @test_use_native_rsqrt
|
; GCN-LABEL: {{^}}define amdgpu_kernel void @test_use_native_rsqrt
|
||||||
; GCN-NATIVE: tail call fast float @_Z12native_rsqrtf(float %tmp)
|
; GCN-NATIVE: tail call fast float @_Z12native_rsqrtf(float %tmp)
|
||||||
|
Loading…
Reference in New Issue
Block a user