aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorKevin P. Neal <kevin.neal@sas.com>2022-03-18 10:22:15 -0400
committerKevin P. Neal <kevin.neal@sas.com>2022-03-18 10:24:48 -0400
commitbd050a34febbd26c60ff1f0fe23f5150914c9e6f (patch)
tree75fdcf6068bbcc65a7a26ab61f500f2ed45b5c48 /llvm/lib/Analysis/ValueTracking.cpp
parentc59c2b6bd19eb7625f7c234eb68d347d8de17079 (diff)
downloadllvm-bd050a34febbd26c60ff1f0fe23f5150914c9e6f.zip
llvm-bd050a34febbd26c60ff1f0fe23f5150914c9e6f.tar.gz
llvm-bd050a34febbd26c60ff1f0fe23f5150914c9e6f.tar.bz2
[FPEnv][InstSimplify] Teach CannotBeNegativeZero() about constrained intrinsics.
Currently some optimizations are disabled because llvm::CannotBeNegativeZero() does not know how to deal with the constrained intrinsics. This patch fixes that by extending the existing implementation. Differential Revision: https://reviews.llvm.org/D121483
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 457e1b2..0cdfa5b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -3397,9 +3397,6 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(const CallBase &CB,
/// NOTE: Do not check 'nsz' here because that fast-math-flag does not guarantee
/// that a value is not -0.0. It only guarantees that -0.0 may be treated
/// the same as +0.0 in floating-point ops.
-///
-/// NOTE: this function will need to be revisited when we support non-default
-/// rounding modes!
bool llvm::CannotBeNegativeZero(const Value *V, const TargetLibraryInfo *TLI,
unsigned Depth) {
if (auto *CFP = dyn_cast<ConstantFP>(V))
@@ -3429,9 +3426,21 @@ bool llvm::CannotBeNegativeZero(const Value *V, const TargetLibraryInfo *TLI,
case Intrinsic::sqrt:
case Intrinsic::canonicalize:
return CannotBeNegativeZero(Call->getArgOperand(0), TLI, Depth + 1);
+ case Intrinsic::experimental_constrained_sqrt: {
+ // NOTE: This rounding mode restriction may be too strict.
+ const auto *CI = cast<ConstrainedFPIntrinsic>(Call);
+ if (CI->getRoundingMode() == RoundingMode::NearestTiesToEven)
+ return CannotBeNegativeZero(Call->getArgOperand(0), TLI, Depth + 1);
+ else
+ return false;
+ }
// fabs(x) != -0.0
case Intrinsic::fabs:
return true;
+ // sitofp and uitofp turn into +0.0 for zero.
+ case Intrinsic::experimental_constrained_sitofp:
+ case Intrinsic::experimental_constrained_uitofp:
+ return true;
}
}