[PATCH] D37223: [AMDGPU] Fix regression in AMDGPULibCalls allowing native for doubles

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 11:01:21 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL311900: [AMDGPU] Fix regression in AMDGPULibCalls allowing native for doubles (authored by rampitec).

Changed prior to commit:
  https://reviews.llvm.org/D37223?vs=112918&id=112920#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37223

Files:
  llvm/trunk/lib/Target/AMDGPU/AMDGPULibCalls.cpp
  llvm/trunk/test/CodeGen/AMDGPU/simplify-libcalls.ll


Index: llvm/trunk/test/CodeGen/AMDGPU/simplify-libcalls.ll
===================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/simplify-libcalls.ll
+++ llvm/trunk/test/CodeGen/AMDGPU/simplify-libcalls.ll
@@ -641,7 +641,18 @@
   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 double @_Z4sqrtd(double)
 
 ; GCN-LABEL: {{^}}define amdgpu_kernel void @test_use_native_rsqrt
 ; GCN-NATIVE: tail call fast float @_Z12native_rsqrtf(float %tmp)
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPULibCalls.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -1170,17 +1170,17 @@
 
 // Get a scalar native builtin signle argument FP function
 Constant* AMDGPULibCalls::getNativeFunction(Module* M, const FuncInfo& FInfo) {
+  if (getArgType(FInfo) == AMDGPULibFunc::F64 || !HasNative(FInfo.getId()))
+    return nullptr;
   FuncInfo nf = FInfo;
   nf.setPrefix(AMDGPULibFunc::NATIVE);
   return getFunction(M, nf);
 }
 
 // fold sqrt -> native_sqrt (x)
 bool AMDGPULibCalls::fold_sqrt(CallInst *CI, IRBuilder<> &B,
                                const FuncInfo &FInfo) {
-  if ((getArgType(FInfo) == AMDGPULibFunc::F32 ||
-       getArgType(FInfo) == AMDGPULibFunc::F64) &&
-      (getVecSize(FInfo) == 1) &&
+  if (getArgType(FInfo) == AMDGPULibFunc::F32 && (getVecSize(FInfo) == 1) &&
       (FInfo.getPrefix() != AMDGPULibFunc::NATIVE)) {
     if (Constant *FPExpr = getNativeFunction(
         CI->getModule(), AMDGPULibFunc(AMDGPULibFunc::EI_SQRT, FInfo))) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37223.112920.patch
Type: text/x-patch
Size: 2043 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170828/318e0cee/attachment-0001.bin>


More information about the llvm-commits mailing list