diff options
author | Ramkumar Ramachandra <ramkumar.ramachandra@codasip.com> | 2024-12-03 13:31:04 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-03 13:31:04 +0000 |
commit | 51a895aded890e90493be59f7af0fa5a3b9b85aa (patch) | |
tree | 95a1d4867c6a39384733d5a1f5c35d5c95ae6f4e /llvm/lib/Analysis/ValueTracking.cpp | |
parent | f33536468b7f05c05c8cf8088427b0b5b665eb65 (diff) | |
download | llvm-51a895aded890e90493be59f7af0fa5a3b9b85aa.zip llvm-51a895aded890e90493be59f7af0fa5a3b9b85aa.tar.gz llvm-51a895aded890e90493be59f7af0fa5a3b9b85aa.tar.bz2 |
IR: introduce struct with CmpInst::Predicate and samesign (#116867)
Introduce llvm::CmpPredicate, an abstraction over a floating-point
predicate, and a pack of an integer predicate with samesign information,
in order to ease extending large portions of the codebase that take a
CmpInst::Predicate to respect the samesign flag.
We have chosen to demonstrate the utility of this new abstraction by
migrating parts of ValueTracking, InstructionSimplify, and InstCombine
from CmpInst::Predicate to llvm::CmpPredicate. There should be no
functional changes, as we don't perform any extra optimizations with
samesign in this patch, or use CmpPredicate::getMatching.
The design approach taken by this patch allows for unaudited callers of
APIs that take a llvm::CmpPredicate to silently drop the samesign
information; it does not pose a correctness issue, and allows us to
migrate the codebase piece-wise.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index d81546d..f2c6949 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -9379,7 +9379,7 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS, (LPred == ICmpInst::ICMP_ULT || LPred == ICmpInst::ICMP_UGE) && (RPred == ICmpInst::ICMP_ULT || RPred == ICmpInst::ICMP_UGE) && match(L0, m_c_Add(m_Specific(L1), m_Specific(R1)))) - return LPred == RPred; + return CmpPredicate::getMatching(LPred, RPred).has_value(); if (LPred == RPred) return isImpliedCondOperands(LPred, L0, L1, R0, R1); @@ -9392,7 +9392,7 @@ static std::optional<bool> isImpliedCondICmps(const ICmpInst *LHS, /// expect the RHS to be an icmp and the LHS to be an 'and', 'or', or a 'select' /// instruction. static std::optional<bool> -isImpliedCondAndOr(const Instruction *LHS, CmpInst::Predicate RHSPred, +isImpliedCondAndOr(const Instruction *LHS, CmpPredicate RHSPred, const Value *RHSOp0, const Value *RHSOp1, const DataLayout &DL, bool LHSIsTrue, unsigned Depth) { // The LHS must be an 'or', 'and', or a 'select' instruction. @@ -9422,7 +9422,7 @@ isImpliedCondAndOr(const Instruction *LHS, CmpInst::Predicate RHSPred, } std::optional<bool> -llvm::isImpliedCondition(const Value *LHS, CmpInst::Predicate RHSPred, +llvm::isImpliedCondition(const Value *LHS, CmpPredicate RHSPred, const Value *RHSOp0, const Value *RHSOp1, const DataLayout &DL, bool LHSIsTrue, unsigned Depth) { // Bail out when we hit the limit. @@ -9476,7 +9476,7 @@ std::optional<bool> llvm::isImpliedCondition(const Value *LHS, const Value *RHS, if (const ICmpInst *RHSCmp = dyn_cast<ICmpInst>(RHS)) { if (auto Implied = isImpliedCondition( - LHS, RHSCmp->getPredicate(), RHSCmp->getOperand(0), + LHS, RHSCmp->getCmpPredicate(), RHSCmp->getOperand(0), RHSCmp->getOperand(1), DL, LHSIsTrue, Depth)) return InvertRHS ? !*Implied : *Implied; return std::nullopt; @@ -9553,7 +9553,7 @@ std::optional<bool> llvm::isImpliedByDomCondition(const Value *Cond, return std::nullopt; } -std::optional<bool> llvm::isImpliedByDomCondition(CmpInst::Predicate Pred, +std::optional<bool> llvm::isImpliedByDomCondition(CmpPredicate Pred, const Value *LHS, const Value *RHS, const Instruction *ContextI, |