[llvm] r255658 - AMDGPU: mark ldexp LibCalls as unavailable

Nicolai Hahnle via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 09:24:16 PST 2015


Author: nha
Date: Tue Dec 15 11:24:15 2015
New Revision: 255658

URL: http://llvm.org/viewvc/llvm-project?rev=255658&view=rev
Log:
AMDGPU: mark ldexp LibCalls as unavailable

Summary:
The LibCallSimplifier will turn llvm.exp2.* intrinsics into ldexp* libcalls
which do not make sense with the AMDGPU backend.

In the long run, we'll want an llvm.ldexp.* intrinsic to properly make use of
this optimization, but this works around the problem for now.

See also: http://reviews.llvm.org/D14327 (suggested llvm.ldexp.* implementation)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92709

Reviewers: arsenm, tstellarAMD

Differential Revision: http://reviews.llvm.org/D14990

Modified:
    llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
    llvm/trunk/test/Transforms/InstCombine/exp2-1.ll

Modified: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp?rev=255658&r1=255657&r2=255658&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp Tue Dec 15 11:24:15 2015
@@ -61,6 +61,13 @@ static void initialize(TargetLibraryInfo
   }
 #endif // !NDEBUG
 
+  if (T.getArch() == Triple::r600 ||
+      T.getArch() == Triple::amdgcn) {
+    TLI.setUnavailable(LibFunc::ldexp);
+    TLI.setUnavailable(LibFunc::ldexpf);
+    TLI.setUnavailable(LibFunc::ldexpl);
+  }
+
   // There are no library implementations of mempcy and memset for AMD gpus and
   // these can be difficult to lower in the backend.
   if (T.getArch() == Triple::r600 ||

Modified: llvm/trunk/test/Transforms/InstCombine/exp2-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/exp2-1.ll?rev=255658&r1=255657&r2=255658&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/exp2-1.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/exp2-1.ll Tue Dec 15 11:24:15 2015
@@ -1,7 +1,8 @@
 ; Test that the exp2 library call simplifier works correctly.
 ;
-; RUN: opt < %s -instcombine -S | FileCheck %s
-; RUN: opt < %s -instcombine -S -mtriple=i386-pc-win32 | FileCheck %s -check-prefix=CHECK-WIN
+; RUN: opt < %s -instcombine -S | FileCheck %s -check-prefix=CHECK -check-prefix=INTRINSIC -check-prefix=LDEXP -check-prefix=LDEXPF
+; RUN: opt < %s -instcombine -S -mtriple=i386-pc-win32 | FileCheck %s -check-prefix=INTRINSIC -check-prefix=LDEXP -check-prefix=NOLDEXPF
+; RUN: opt < %s -instcombine -S -mtriple=amdgcn-unknown-unknown | FileCheck %s -check-prefix=INTRINSIC -check-prefix=NOLDEXP -check-prefix=NOLDEXPF
 
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
 
@@ -80,21 +81,19 @@ declare double @llvm.exp2.f64(double)
 declare float @llvm.exp2.f32(float)
 
 define double @test_simplify9(i8 zeroext %x) {
-; CHECK-LABEL: @test_simplify9(
-; CHECK-WIN-LABEL: @test_simplify9(
+; INTRINSIC-LABEL: @test_simplify9(
   %conv = uitofp i8 %x to double
   %ret = call double @llvm.exp2.f64(double %conv)
-; CHECK: call double @ldexp
-; CHECK-WIN: call double @ldexp
+; LDEXP: call double @ldexp
+; NOLDEXP-NOT: call double @ldexp
   ret double %ret
 }
 
 define float @test_simplify10(i8 zeroext %x) {
-; CHECK-LABEL: @test_simplify10(
-; CHECK-WIN-LABEL: @test_simplify10(
+; INTRINSIC-LABEL: @test_simplify10(
   %conv = uitofp i8 %x to float
   %ret = call float @llvm.exp2.f32(float %conv)
-; CHECK: call float @ldexpf
-; CHECK-WIN-NOT: call float @ldexpf
+; LDEXPF: call float @ldexpf
+; NOLDEXPF-NOT: call float @ldexpf
   ret float %ret
 }




More information about the llvm-commits mailing list