[llvm] b357f37 - Revert "SimplifyLibCalls: Pass AssumptionCache to isKnownNeverInfinity"

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 23:32:20 PDT 2023


Author: Alina Sbirlea
Date: 2023-05-18T23:31:51-07:00
New Revision: b357f379c81811409348dd0e0273a248b055bb7a

URL: https://github.com/llvm/llvm-project/commit/b357f379c81811409348dd0e0273a248b055bb7a
DIFF: https://github.com/llvm/llvm-project/commit/b357f379c81811409348dd0e0273a248b055bb7a.diff

LOG: Revert "SimplifyLibCalls: Pass AssumptionCache to isKnownNeverInfinity"

This reverts commit faa32734bf9a55fa3f91d91f6fdf0f8a951a9c0e.
Revert due to test failures introduced by 73925ef8b0eacc6792f0e3ea21a3e6d51f5ee8b0

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
    llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
    llvm/test/Transforms/InstCombine/pow-1.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
index eb10545ee149e..9269216d06789 100644
--- a/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
+++ b/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
@@ -18,7 +18,6 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 
 namespace llvm {
-class AssumptionCache;
 class StringRef;
 class Value;
 class CallInst;
@@ -103,7 +102,6 @@ class LibCallSimplifier {
   FortifiedLibCallSimplifier FortifiedSimplifier;
   const DataLayout &DL;
   const TargetLibraryInfo *TLI;
-  AssumptionCache *AC;
   OptimizationRemarkEmitter &ORE;
   BlockFrequencyInfo *BFI;
   ProfileSummaryInfo *PSI;
@@ -136,9 +134,9 @@ class LibCallSimplifier {
 
 public:
   LibCallSimplifier(
-      const DataLayout &DL, const TargetLibraryInfo *TLI, AssumptionCache *AC,
-      OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
-      ProfileSummaryInfo *PSI,
+      const DataLayout &DL, const TargetLibraryInfo *TLI,
+      OptimizationRemarkEmitter &ORE,
+      BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI,
       function_ref<void(Instruction *, Value *)> Replacer =
           &replaceAllUsesWithDefault,
       function_ref<void(Instruction *)> Eraser = &eraseFromParentDefault);

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 1d7bf48414a13..2992d163344d9 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3239,7 +3239,7 @@ Instruction *InstCombinerImpl::tryOptimizeCall(CallInst *CI) {
   auto InstCombineErase = [this](Instruction *I) {
     eraseInstFromFunction(*I);
   };
-  LibCallSimplifier Simplifier(DL, &TLI, &AC, ORE, BFI, PSI, InstCombineRAUW,
+  LibCallSimplifier Simplifier(DL, &TLI, ORE, BFI, PSI, InstCombineRAUW,
                                InstCombineErase);
   if (Value *With = Simplifier.optimizeCall(CI, Builder)) {
     ++NumSimplified;

diff  --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 220f0b271d81b..190b17f177a9a 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2179,7 +2179,7 @@ Value *LibCallSimplifier::replacePowWithSqrt(CallInst *Pow, IRBuilderBase &B) {
   // pow(-Inf, 0.5) is optionally required to have a result of +Inf (not setting
   // errno), but sqrt(-Inf) is required by various standards to set errno.
   if (!Pow->doesNotAccessMemory() && !Pow->hasNoInfs() &&
-      !isKnownNeverInfinity(Base, DL, TLI, 0, AC, Pow, /*DT=*/nullptr, &ORE))
+      !isKnownNeverInfinity(Base, DL, TLI))
     return nullptr;
 
   Sqrt = getSqrtCall(Base, AttributeList(), Pow->doesNotAccessMemory(), Mod, B,
@@ -3837,13 +3837,13 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI, IRBuilderBase &Builder) {
 }
 
 LibCallSimplifier::LibCallSimplifier(
-    const DataLayout &DL, const TargetLibraryInfo *TLI, AssumptionCache *AC,
-    OptimizationRemarkEmitter &ORE, BlockFrequencyInfo *BFI,
-    ProfileSummaryInfo *PSI,
+    const DataLayout &DL, const TargetLibraryInfo *TLI,
+    OptimizationRemarkEmitter &ORE,
+    BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI,
     function_ref<void(Instruction *, Value *)> Replacer,
     function_ref<void(Instruction *)> Eraser)
-    : FortifiedSimplifier(TLI), DL(DL), TLI(TLI), AC(AC), ORE(ORE), BFI(BFI),
-      PSI(PSI), Replacer(Replacer), Eraser(Eraser) {}
+    : FortifiedSimplifier(TLI), DL(DL), TLI(TLI), ORE(ORE), BFI(BFI), PSI(PSI),
+      Replacer(Replacer), Eraser(Eraser) {}
 
 void LibCallSimplifier::replaceAllUsesWith(Instruction *I, Value *With) {
   // Indirect through the replacer used in this instance.

diff  --git a/llvm/test/Transforms/InstCombine/pow-1.ll b/llvm/test/Transforms/InstCombine/pow-1.ll
index d1f587f7ce089..f93d3586d95d2 100644
--- a/llvm/test/Transforms/InstCombine/pow-1.ll
+++ b/llvm/test/Transforms/InstCombine/pow-1.ll
@@ -20,12 +20,10 @@
 
 declare float @powf(float, float) nounwind readonly
 declare float @llvm.pow.f32(float, float)
-declare float @llvm.fabs.f32(float)
 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
 declare <2 x double> @llvm.pow.v2f64(<2 x double>, <2 x double>) nounwind readonly
-declare void @llvm.assume(i1 noundef)
 
 ; Check pow(1.0, x) -> 1.0.
 
@@ -272,72 +270,6 @@ define float @powf_libcall_half_ninf(float %x) {
   ret float %retval
 }
 
-; Make sure assume works when inferring no infinities
-define float @powf_libcall_half_assume_ninf(float %x) {
-; ANY-LABEL: define float @powf_libcall_half_assume_ninf
-; ANY-SAME: (float [[X:%.*]]) {
-; ANY-NEXT:    [[FABS:%.*]] = call float @llvm.fabs.f32(float [[X]])
-; ANY-NEXT:    [[NOT_INF:%.*]] = fcmp one float [[FABS]], 0x7FF0000000000000
-; ANY-NEXT:    call void @llvm.assume(i1 [[NOT_INF]])
-; ANY-NEXT:    [[SQRTF:%.*]] = call float @sqrtf(float [[X]])
-; ANY-NEXT:    [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]])
-; ANY-NEXT:    [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000
-; ANY-NEXT:    [[RETVAL:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]]
-; ANY-NEXT:    ret float [[RETVAL]]
-;
-; VC32-LABEL: define float @powf_libcall_half_assume_ninf
-; VC32-SAME: (float [[X:%.*]]) {
-; VC32-NEXT:    [[FABS:%.*]] = call float @llvm.fabs.f32(float [[X]])
-; VC32-NEXT:    [[NOT_INF:%.*]] = fcmp one float [[FABS]], 0x7FF0000000000000
-; VC32-NEXT:    call void @llvm.assume(i1 [[NOT_INF]])
-; VC32-NEXT:    [[RETVAL:%.*]] = call float @powf(float [[X]], float 5.000000e-01)
-; VC32-NEXT:    ret float [[RETVAL]]
-;
-; VC51-LABEL: define float @powf_libcall_half_assume_ninf
-; VC51-SAME: (float [[X:%.*]]) {
-; VC51-NEXT:    [[FABS:%.*]] = call float @llvm.fabs.f32(float [[X]])
-; VC51-NEXT:    [[NOT_INF:%.*]] = fcmp one float [[FABS]], 0x7FF0000000000000
-; VC51-NEXT:    call void @llvm.assume(i1 [[NOT_INF]])
-; VC51-NEXT:    [[RETVAL:%.*]] = call float @powf(float [[X]], float 5.000000e-01)
-; VC51-NEXT:    ret float [[RETVAL]]
-;
-; VC64-LABEL: define float @powf_libcall_half_assume_ninf
-; VC64-SAME: (float [[X:%.*]]) {
-; VC64-NEXT:    [[FABS:%.*]] = call float @llvm.fabs.f32(float [[X]])
-; VC64-NEXT:    [[NOT_INF:%.*]] = fcmp one float [[FABS]], 0x7FF0000000000000
-; VC64-NEXT:    call void @llvm.assume(i1 [[NOT_INF]])
-; VC64-NEXT:    [[SQRTF:%.*]] = call float @sqrtf(float [[X]])
-; VC64-NEXT:    [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]])
-; VC64-NEXT:    [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000
-; VC64-NEXT:    [[RETVAL:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]]
-; VC64-NEXT:    ret float [[RETVAL]]
-;
-; VC83-LABEL: define float @powf_libcall_half_assume_ninf
-; VC83-SAME: (float [[X:%.*]]) {
-; VC83-NEXT:    [[FABS:%.*]] = call float @llvm.fabs.f32(float [[X]])
-; VC83-NEXT:    [[NOT_INF:%.*]] = fcmp one float [[FABS]], 0x7FF0000000000000
-; VC83-NEXT:    call void @llvm.assume(i1 [[NOT_INF]])
-; VC83-NEXT:    [[SQRTF:%.*]] = call float @sqrtf(float [[X]])
-; VC83-NEXT:    [[ABS:%.*]] = call float @llvm.fabs.f32(float [[SQRTF]])
-; VC83-NEXT:    [[ISINF:%.*]] = fcmp oeq float [[X]], 0xFFF0000000000000
-; VC83-NEXT:    [[RETVAL:%.*]] = select i1 [[ISINF]], float 0x7FF0000000000000, float [[ABS]]
-; VC83-NEXT:    ret float [[RETVAL]]
-;
-; NOLIB-LABEL: define float @powf_libcall_half_assume_ninf
-; NOLIB-SAME: (float [[X:%.*]]) {
-; NOLIB-NEXT:    [[FABS:%.*]] = call float @llvm.fabs.f32(float [[X]])
-; NOLIB-NEXT:    [[NOT_INF:%.*]] = fcmp one float [[FABS]], 0x7FF0000000000000
-; NOLIB-NEXT:    call void @llvm.assume(i1 [[NOT_INF]])
-; NOLIB-NEXT:    [[RETVAL:%.*]] = call float @powf(float [[X]], float 5.000000e-01)
-; NOLIB-NEXT:    ret float [[RETVAL]]
-;
-  %fabs = call float @llvm.fabs.f32(float %x)
-  %not.inf = fcmp one float %fabs, 0x7FF0000000000000
-  call void @llvm.assume(i1 %not.inf)
-  %retval = call float @powf(float %x, float 0.5)
-  ret float %retval
-}
-
 define float @powf_libcall_half_ninf_tail(float %x) {
 ; CHECK-LABEL: @powf_libcall_half_ninf_tail(
 ; ANY-NEXT:      %sqrtf = call ninf float @sqrtf(float %x)


        


More information about the llvm-commits mailing list