[llvm] Enable exp10 libcall on linux (PR #68736)

Krishna Narayanan via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 11:37:36 PDT 2023


https://github.com/Krishna-13-cyber created https://github.com/llvm/llvm-project/pull/68736

None

>From d342e99a8805502492c74b90ef86aedc81856438 Mon Sep 17 00:00:00 2001
From: Krishna-13-cyber <krishnanarayanan132002 at gmail.com>
Date: Tue, 10 Oct 2023 23:48:26 +0530
Subject: [PATCH] Enable exp10 libcall on linux

---
 llvm/lib/Analysis/TargetLibraryInfo.cpp                  | 9 +++------
 .../test/Transforms/InstCombine/double-float-shrink-1.ll | 6 ------
 llvm/test/Transforms/InstCombine/pow-1.ll                | 7 +++++--
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 7b38583e9bc75f0..18f193f9775e01e 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -562,12 +562,9 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
     // or we have a reasonable detection strategy, we cannot use exp10 reliably
     // on Linux.
     //
-    // Fall through to disable all of them.
-    [[fallthrough]];
-  default:
-    TLI.setUnavailable(LibFunc_exp10);
-    TLI.setUnavailable(LibFunc_exp10f);
-    TLI.setUnavailable(LibFunc_exp10l);
+    TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
+    TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
+    break;
   }
 
   // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
diff --git a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
index 85c9a01e5fababd..e3c5f3c08efe939 100644
--- a/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
+++ b/llvm/test/Transforms/InstCombine/double-float-shrink-1.ll
@@ -224,12 +224,6 @@ define double @expm1_test2(float %f)   {
 ; exp10f() doesn't exist for this triple, so it doesn't shrink.
 
 define float @exp10_test1(float %f)   {
-; CHECK-LABEL: @exp10_test1(
-; CHECK-NEXT:    [[CONV:%.*]] = fpext float [[F:%.*]] to double
-; CHECK-NEXT:    [[CALL:%.*]] = call fast double @exp10(double [[CONV]])
-; CHECK-NEXT:    [[CONV1:%.*]] = fptrunc double [[CALL]] to float
-; CHECK-NEXT:    ret float [[CONV1]]
-;
   %conv = fpext float %f to double
   %call = call fast double @exp10(double %conv)
   %conv1 = fptrunc double %call to float
diff --git a/llvm/test/Transforms/InstCombine/pow-1.ll b/llvm/test/Transforms/InstCombine/pow-1.ll
index 16eca3d8f2d0f8a..be259a217250f72 100644
--- a/llvm/test/Transforms/InstCombine/pow-1.ll
+++ b/llvm/test/Transforms/InstCombine/pow-1.ll
@@ -14,6 +14,7 @@
 ; RUN: opt -passes=instcombine -S < %s -mtriple=x86_64-pc-windows-msvc18 | FileCheck %s --check-prefixes=CHECK,LIB,MSVC,VC64,CHECK-NO-EXP10
 ; RUN: opt -passes=instcombine -S < %s -mtriple=x86_64-pc-windows-msvc   | FileCheck %s --check-prefixes=CHECK,LIB,MSVC,VC83,VC19,CHECK-NO-EXP10
 ; RUN: opt -passes=instcombine -S < %s -mtriple=amdgcn--                 | FileCheck %s --check-prefixes=CHECK,NOLIB,CHECK-NO-EXP10
+; RUN: opt -passes=instcombine -S < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=CHECK,NOLIB,CHECK-NO-EXP10
 
 ; NOTE: The readonly attribute on the pow call should be preserved
 ; in the cases below where pow is transformed into another function call.
@@ -21,6 +22,8 @@
 declare float @powf(float, float) nounwind readonly
 declare float @llvm.pow.f32(float, float)
 declare float @llvm.fabs.f32(float)
+declare float @exp10f(float) nounwind readonly
+declare double @exp10(double) nounwind readonly
 declare double @pow(double, double) nounwind readonly
 declare double @llvm.pow.f64(double, double)
 declare <2 x float> @llvm.pow.v2f32(<2 x float>, <2 x float>) nounwind readonly
@@ -559,7 +562,7 @@ define double @pow_intrinsic_half_no_FMF(double %x) {
 
 define float @test_simplify18(float %x) {
 ; CHECK-LABEL:          @test_simplify18(
-; CHECK-EXP10-NEXT:     [[__EXP10F:%.*]] = call float @__exp10f(float [[X:%.*]])
+; CHECK-EXP10-NEXT:     [[__EXP10F:%.*]] = call float @exp10f(float [[X:%.*]])
 ; CHECK-EXP10-NEXT:     ret float [[__EXP10F]]
 ; CHECK-NO-EXP10-NEXT:  [[RETVAL:%.*]] = call float @powf(float 1.000000e+01, float [[X:%.*]])
 ; CHECK-NO-EXP10-NEXT:  ret float [[RETVAL]]
@@ -570,7 +573,7 @@ define float @test_simplify18(float %x) {
 
 define double @test_simplify19(double %x) {
 ; CHECK-LABEL:          @test_simplify19(
-; CHECK-EXP10-NEXT:     [[__EXP10:%.*]] = call double @__exp10(double [[X:%.*]])
+; CHECK-EXP10-NEXT:     [[__EXP10:%.*]] = call double @exp10(double [[X:%.*]])
 ; CHECK-EXP10-NEXT:     ret double [[__EXP10]]
 ; CHECK-NO-EXP10-NEXT:  [[RETVAL:%.*]] = call double @pow(double 1.000000e+01, double [[X:%.*]])
 ; CHECK-NO-EXP10-NEXT:  ret double [[RETVAL]]



More information about the llvm-commits mailing list