[PATCH] D67406: [TLI][AMDGPU] AMDPAL does not have tan function

Tim Renouf via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 09:13:29 PDT 2019


tpr created this revision.
Herald added subscribers: llvm-commits, t-tye, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
Herald added a project: LLVM.

The LLPC frontend for AMDPAL OS type does not have a tan library
function, so disable instcombine generating it. We are only just coming
across this issue in LLPC as we start setting fast math flags.

Change-Id: I02f907d3e64832117ea9800e9f9285282856e5df


Repository:
  rL LLVM

https://reviews.llvm.org/D67406

Files:
  lib/Analysis/TargetLibraryInfo.cpp
  test/Transforms/InstCombine/AMDGPU/tan.ll


Index: test/Transforms/InstCombine/AMDGPU/tan.ll
===================================================================
--- /dev/null
+++ test/Transforms/InstCombine/AMDGPU/tan.ll
@@ -0,0 +1,21 @@
+; RUN: opt -mtriple=amdgcn--amdpal -S -instcombine <%s | FileCheck --check-prefixes=GCN,GCNPAL %s
+; RUN: opt -mtriple=amdgcn-- -S -instcombine <%s | FileCheck --check-prefixes=GCN,GCNOTHER %s
+
+; GCN-LABEL: define amdgpu_ps float @llpc.shader.FS.main
+; GCNPAL: call float @llvm.sin.f32
+; GCNPAL: call float @llvm.cos.f32
+; GCNOTHER: call {{.*}} @tanf(float
+
+declare float @llvm.sin.f32(float) #0
+declare float @llvm.cos.f32(float) #0
+
+define amdgpu_ps float @llpc.shader.FS.main(float %arg) {
+.entry:
+  %tmp32 = call float @llvm.sin.f32(float %arg)
+  %tmp33 = call float @llvm.cos.f32(float %arg)
+  %tmp34 = fdiv reassoc nnan nsz arcp contract float 1.000000e+00, %tmp33
+  %tmp35 = fmul reassoc nnan nsz arcp contract float %tmp32, %tmp34
+  ret float %tmp35
+}
+
+attributes #0 = { nounwind readnone speculatable willreturn }
Index: lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- lib/Analysis/TargetLibraryInfo.cpp
+++ lib/Analysis/TargetLibraryInfo.cpp
@@ -114,6 +114,12 @@
     TLI.setUnavailable(LibFunc_log10);
     TLI.setUnavailable(LibFunc_log10f);
     TLI.setUnavailable(LibFunc_log10l);
+    // For PAL OS, we do not have a tan function.
+    if (T.getOS() == Triple::AMDPAL) {
+      TLI.setUnavailable(LibFunc_tan);
+      TLI.setUnavailable(LibFunc_tanf);
+      TLI.setUnavailable(LibFunc_tanl);
+    }
   }
 
   // There are no library implementations of memcpy and memset for AMD gpus and


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67406.219558.patch
Type: text/x-patch
Size: 1676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190910/2b48ed59/attachment.bin>


More information about the llvm-commits mailing list