[llvm] 4490cfb - [ValueTracking] peek through fpext in isKnownNeverInfinity()

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 2 08:32:23 PDT 2022


Author: Sanjay Patel
Date: 2022-10-02T11:20:23-04:00
New Revision: 4490cfbaf4591febc784592fa11a9d418e6c8d5a

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

LOG: [ValueTracking] peek through fpext in isKnownNeverInfinity()

https://alive2.llvm.org/ce/z/BkNoRW

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 ddc96f7524e18..4d631945b441e 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3801,6 +3801,10 @@ bool llvm::isKnownNeverInfinity(const Value *V, const TargetLibraryInfo *TLI,
       Type *FPTy = Inst->getType()->getScalarType();
       return ilogb(APFloat::getLargest(FPTy->getFltSemantics())) >= IntSize;
     }
+    case Instruction::FPExt: {
+      // Peek through to source op. If it is not infinity, this is not infinity.
+      return isKnownNeverInfinity(Inst->getOperand(0), TLI, Depth + 1);
+    }
     default:
       break;
     }

diff  --git a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
index 3ff39b04b09b2..df0ad624f2084 100644
--- a/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
+++ b/llvm/test/Transforms/InstSimplify/floating-point-compare.ll
@@ -1249,10 +1249,7 @@ define i1 @isNotKnownNeverNegativeInfinity_sitofp(i17 %x) {
 
 define i1 @isKnownNeverInfinity_fpext(float %x) {
 ; CHECK-LABEL: @isKnownNeverInfinity_fpext(
-; CHECK-NEXT:    [[A:%.*]] = fadd ninf float [[X:%.*]], 1.000000e+00
-; CHECK-NEXT:    [[E:%.*]] = fpext float [[A]] to double
-; CHECK-NEXT:    [[R:%.*]] = fcmp une double [[E]], 0x7FF0000000000000
-; CHECK-NEXT:    ret i1 [[R]]
+; CHECK-NEXT:    ret i1 true
 ;
   %a = fadd ninf float %x, 1.0
   %e = fpext float %a to double
@@ -1262,10 +1259,7 @@ define i1 @isKnownNeverInfinity_fpext(float %x) {
 
 define i1 @isKnownNeverInfinity_fpext_sitofp(i16 %x) {
 ; CHECK-LABEL: @isKnownNeverInfinity_fpext_sitofp(
-; CHECK-NEXT:    [[F:%.*]] = sitofp i16 [[X:%.*]] to half
-; CHECK-NEXT:    [[E:%.*]] = fpext half [[F]] to double
-; CHECK-NEXT:    [[R:%.*]] = fcmp oeq double [[E]], 0xFFF0000000000000
-; CHECK-NEXT:    ret i1 [[R]]
+; CHECK-NEXT:    ret i1 false
 ;
   %f = sitofp i16 %x to half
   %e = fpext half %f to double


        


More information about the llvm-commits mailing list