[llvm] db0f258 - ValueTracking: Teach isKnownNeverNaN about arithmetic_fence

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 05:39:16 PST 2022


Author: Matt Arsenault
Date: 2022-12-05T08:39:07-05:00
New Revision: db0f258479e3bdf3db9fb231d8f3f2fa05a41e0b

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

LOG: ValueTracking: Teach isKnownNeverNaN about arithmetic_fence

Added: 
    

Modified: 
    llvm/lib/Analysis/ValueTracking.cpp
    llvm/test/Transforms/InstSimplify/known-never-nan.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 86c28ea1f736..e86e9d1502d3 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3893,6 +3893,7 @@ bool llvm::isKnownNeverNaN(const Value *V, const TargetLibraryInfo *TLI,
     case Intrinsic::nearbyint:
     case Intrinsic::round:
     case Intrinsic::roundeven:
+    case Intrinsic::arithmetic_fence:
       return isKnownNeverNaN(II->getArgOperand(0), TLI, Depth + 1);
     case Intrinsic::sqrt:
       return isKnownNeverNaN(II->getArgOperand(0), TLI, Depth + 1) &&

diff  --git a/llvm/test/Transforms/InstSimplify/known-never-nan.ll b/llvm/test/Transforms/InstSimplify/known-never-nan.ll
index d6a2924a0215..e9114bb19d6e 100644
--- a/llvm/test/Transforms/InstSimplify/known-never-nan.ll
+++ b/llvm/test/Transforms/InstSimplify/known-never-nan.ll
@@ -412,6 +412,16 @@ define i1 @nnan_frem(double %arg0, double %arg1) {
   ret i1 %tmp
 }
 
+define i1 @nnan_arithemtic_fence_src(double %arg) {
+; CHECK-LABEL: @nnan_arithemtic_fence_src(
+; CHECK-NEXT:    ret i1 true
+;
+  %nnan = fadd nnan double %arg, 1.0
+  %op = call double @llvm.arithmetic.fence.f64(double %nnan)
+  %tmp = fcmp ord double %op, %op
+  ret i1 %tmp
+}
+
 declare double @llvm.sqrt.f64(double)
 declare double @llvm.fabs.f64(double)
 declare double @llvm.canonicalize.f64(double)
@@ -425,3 +435,4 @@ declare double @llvm.rint.f64(double)
 declare double @llvm.nearbyint.f64(double)
 declare double @llvm.round.f64(double)
 declare double @llvm.roundeven.f64(double)
+declare double @llvm.arithmetic.fence.f64(double)


        


More information about the llvm-commits mailing list