aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2023-04-19 18:51:11 -0400
committerMatt Arsenault <arsenm2@gmail.com>2023-04-21 08:15:04 -0400
commitc55fffecce3e5ddc76d58d9496316213f993e0e7 (patch)
tree6c8bdaaadcfea29b30492fbff3c0404765d93b07 /llvm/lib/Analysis/ValueTracking.cpp
parent8e26a9029c918c71d9f7966262fcce81d1f0d586 (diff)
downloadllvm-c55fffecce3e5ddc76d58d9496316213f993e0e7.zip
llvm-c55fffecce3e5ddc76d58d9496316213f993e0e7.tar.gz
llvm-c55fffecce3e5ddc76d58d9496316213f993e0e7.tar.bz2
ValueTracking: Recognize >=, <= compares with 0 as is.fpclass masks
Leave DAZ handling for a future change.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index cc812cb..c3e0eb7 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4186,9 +4186,11 @@ std::pair<Value *, FPClassTest> llvm::fcmpToClassTest(FCmpInst::Predicate Pred,
return {nullptr, fcNone};
if (ConstRHS->isZero()) {
- // Compares with fcNone are only exactly equal to fcZero if input denormals are
- // not flushed.
- if (FCmpInst::isEquality(Pred) && !inputDenormalIsIEEE(F, LHS->getType()))
+ // Compares with fcNone are only exactly equal to fcZero if input denormals
+ // are not flushed.
+ // TODO: Handle DAZ by expanding masks to cover subnormal cases.
+ if (Pred != FCmpInst::FCMP_ORD && Pred != FCmpInst::FCMP_UNO &&
+ !inputDenormalIsIEEE(F, LHS->getType()))
return {nullptr, fcNone};
switch (Pred) {
@@ -4206,6 +4208,22 @@ std::pair<Value *, FPClassTest> llvm::fcmpToClassTest(FCmpInst::Predicate Pred,
return {LHS, ~fcNan};
case FCmpInst::FCMP_UNO:
return {LHS, fcNan};
+ case FCmpInst::FCMP_OGT: // x > 0
+ return {LHS, fcPosSubnormal | fcPosNormal | fcPosInf};
+ case FCmpInst::FCMP_UGT: // isnan(x) || x > 0
+ return {LHS, fcPosSubnormal | fcPosNormal | fcPosInf | fcNan};
+ case FCmpInst::FCMP_OGE: // x >= 0
+ return {LHS, fcPositive | fcNegZero};
+ case FCmpInst::FCMP_UGE: // isnan(x) || x >= 0
+ return {LHS, fcPositive | fcNegZero | fcNan};
+ case FCmpInst::FCMP_OLT: // x < 0
+ return {LHS, fcNegSubnormal | fcNegNormal | fcNegInf};
+ case FCmpInst::FCMP_ULT: // isnan(x) || x < 0
+ return {LHS, fcNegSubnormal | fcNegNormal | fcNegInf | fcNan};
+ case FCmpInst::FCMP_OLE: // x <= 0
+ return {LHS, fcNegative | fcPosZero};
+ case FCmpInst::FCMP_ULE: // isnan(x) || x <= 0
+ return {LHS, fcNegative | fcPosZero | fcNan};
default:
break;
}