mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[InstCombine][IR] Add a commutable BinOp matcher. Use it to reduce some code. NFC
llvm-svn: 300030
This commit is contained in:
parent
dbe48d9fbb
commit
32d5ac89d5
@ -1348,6 +1348,14 @@ template <typename Val_t> inline Signum_match<Val_t> m_Signum(const Val_t &V) {
|
||||
// Matchers for two-operands operators with the operators in either order
|
||||
//
|
||||
|
||||
/// \brief Matches a Add with LHS and RHS in either order.
|
||||
template<typename LHS, typename RHS>
|
||||
inline match_combine_or<AnyBinaryOp_match<LHS, RHS>,
|
||||
AnyBinaryOp_match<RHS, LHS>>
|
||||
m_c_BinOp(const LHS &L, const RHS &R) {
|
||||
return m_CombineOr(m_BinOp(L, R), m_BinOp(R, L));
|
||||
}
|
||||
|
||||
/// \brief Matches an ICmp with a predicate over LHS and RHS in either order.
|
||||
/// Does not swap the predicate.
|
||||
template<typename LHS, typename RHS>
|
||||
|
@ -1272,8 +1272,7 @@ Instruction *InstCombiner::visitAnd(BinaryOperator &I) {
|
||||
case Instruction::Sub:
|
||||
Value *X;
|
||||
ConstantInt *C1;
|
||||
if (match(Op0I, m_BinOp(m_ZExt(m_Value(X)), m_ConstantInt(C1))) ||
|
||||
match(Op0I, m_BinOp(m_ConstantInt(C1), m_ZExt(m_Value(X))))) {
|
||||
if (match(Op0I, m_c_BinOp(m_ZExt(m_Value(X)), m_ConstantInt(C1)))) {
|
||||
if (AndRHSMask.isIntN(X->getType()->getScalarSizeInBits())) {
|
||||
auto *TruncC1 = ConstantExpr::getTrunc(C1, X->getType());
|
||||
Value *BinOp;
|
||||
|
Loading…
Reference in New Issue
Block a user