[llvm] 9a21475 - ValueTracking: Teach isKnownNeverInfinity about sqrt

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 10:03:15 PST 2022


Author: Matt Arsenault
Date: 2022-12-20T13:03:07-05:00
New Revision: 9a214756517ffb1bee0308942d6a037ab6012a57

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

LOG: ValueTracking: Teach isKnownNeverInfinity about sqrt

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp
    llvm/test/Transforms/InstSimplify/floating-point-compare.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 4181831c284c..037d2fb02522 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3804,6 +3804,7 @@ bool llvm::isKnownNeverInfinity(const Value *V, const TargetLibraryInfo *TLI,
     if (const auto *II = dyn_cast<IntrinsicInst>(V)) {
       switch (II->getIntrinsicID()) {
       case Intrinsic::fabs:
+      case Intrinsic::sqrt:
       case Intrinsic::canonicalize:
       case Intrinsic::copysign:
       case Intrinsic::arithmetic_fence:

diff  --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index ea51cab60b93..bbd6a7ac3724 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -1819,10 +1819,7 @@ declare double @llvm.maximum.f64(double, double)
 
 define i1 @isKnownNeverInfinity_sqrt(double %x) {
 ; CHECK-LABEL: @isKnownNeverInfinity_sqrt(
-; CHECK-NEXT:    [[A:%.*]] = fadd ninf double [[X:%.*]], 1.000000e+00
-; CHECK-NEXT:    [[E:%.*]] = call double @llvm.sqrt.f64(double [[A]])
-; CHECK-NEXT:    [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
-; CHECK-NEXT:    ret i1 [[R]]
+; CHECK-NEXT:    ret i1 true
 ;
   %a = fadd ninf double %x, 1.0
   %e = call double @llvm.sqrt.f64(double %a)


        


More information about the llvm-commits mailing list