aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2023-11-14 10:05:38 +0900
committerGitHub <noreply@github.com>2023-11-14 10:05:38 +0900
commit0e1a52f556a90cc7b7ce7666fc476c99cf7bfb02 (patch)
treea578f9a412861f9316a14ef8af66bb8f63ce7eea /llvm/lib/Analysis/ValueTracking.cpp
parent45a92acfd945bef2dca391bccd08a09348c35c67 (diff)
downloadllvm-0e1a52f556a90cc7b7ce7666fc476c99cf7bfb02.zip
llvm-0e1a52f556a90cc7b7ce7666fc476c99cf7bfb02.tar.gz
llvm-0e1a52f556a90cc7b7ce7666fc476c99cf7bfb02.tar.bz2
ValueTracking: Handle compare gt to -inf in class identification (#72086)
This apparently shows up somewhere in chromium. We also are missing a canonicalization to an equality compare with inf.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 923ff04..dc3c90b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4181,8 +4181,14 @@ llvm::fcmpToClassTest(FCmpInst::Predicate Pred, const Function &F, Value *LHS,
}
case FCmpInst::FCMP_OGE:
case FCmpInst::FCMP_ULT: {
- if (ConstRHS->isNegative()) // TODO
- return {nullptr, fcAllFlags};
+ if (ConstRHS->isNegative()) {
+ // fcmp oge x, -inf -> ~fcNan
+ // fcmp oge fabs(x), -inf -> ~fcNan
+ // fcmp ult x, -inf -> fcNan
+ // fcmp ult fabs(x), -inf -> fcNan
+ Mask = ~fcNan;
+ break;
+ }
// fcmp oge fabs(x), +inf -> fcInf
// fcmp oge x, +inf -> fcPosInf
@@ -4195,8 +4201,14 @@ llvm::fcmpToClassTest(FCmpInst::Predicate Pred, const Function &F, Value *LHS,
}
case FCmpInst::FCMP_OGT:
case FCmpInst::FCMP_ULE: {
- if (ConstRHS->isNegative())
- return {nullptr, fcAllFlags};
+ if (ConstRHS->isNegative()) {
+ // fcmp ogt x, -inf -> fcmp one x, -inf
+ // fcmp ogt fabs(x), -inf -> fcmp ord x, x
+ // fcmp ule x, -inf -> fcmp ueq x, -inf
+ // fcmp ule fabs(x), -inf -> fcmp uno x, x
+ Mask = IsFabs ? ~fcNan : ~(fcNegInf | fcNan);
+ break;
+ }
// No value is ordered and greater than infinity.
Mask = fcNone;