mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
[InstCombine] Add a new formula for SMIN.
Summary: After this change `MatchSelectPattern` recognizes the following form of SMIN: Y >s C ? ~Y : ~C == ~Y <s ~C ? ~Y : ~C = SMIN(~Y, ~C) Reviewers: majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9352 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -86,6 +86,17 @@ MatchSelectPattern(Value *V, Value *&LHS, Value *&RHS) {
|
||||
return (CmpLHS == FalseVal) ? SPF_ABS : SPF_NABS;
|
||||
}
|
||||
}
|
||||
|
||||
// Y >s C ? ~Y : ~C == ~Y <s ~C ? ~Y : ~C = SMIN(~Y, ~C)
|
||||
if (const auto *C2 = dyn_cast<ConstantInt>(FalseVal)) {
|
||||
if (C1->getType() == C2->getType() && ~C1->getValue() == C2->getValue() &&
|
||||
(match(TrueVal, m_Not(m_Specific(CmpLHS))) ||
|
||||
match(CmpLHS, m_Not(m_Specific(TrueVal))))) {
|
||||
LHS = TrueVal;
|
||||
RHS = FalseVal;
|
||||
return SPF_SMIN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: (X > 4) ? X : 5 --> (X >= 5) ? X : 5 --> MAX(X, 5)
|
||||
|
Reference in New Issue
Block a user