From 9a214756517ffb1bee0308942d6a037ab6012a57 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sun, 4 Dec 2022 09:26:16 -0500 Subject: [PATCH] ValueTracking: Teach isKnownNeverInfinity about sqrt --- llvm/lib/Analysis/ValueTracking.cpp | 1 + llvm/test/Transforms/InstSimplify/floating-point-compare.ll | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 4181831..037d2fb 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(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 ea51cab..bbd6a7a 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) -- 2.7.4