mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-20 16:17:38 +00:00
PatternMatch: Introduce a matcher for instructions with the "exact" bit. Use it to simplify a few matchers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147403 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -812,14 +812,10 @@ static Value *SimplifyMulInst(Value *Op0, Value *Op1, const TargetData *TD,
|
||||
return Op0;
|
||||
|
||||
// (X / Y) * Y -> X if the division is exact.
|
||||
Value *X = 0, *Y = 0;
|
||||
if ((match(Op0, m_IDiv(m_Value(X), m_Value(Y))) && Y == Op1) || // (X / Y) * Y
|
||||
(match(Op1, m_IDiv(m_Value(X), m_Value(Y))) && Y == Op0)) { // Y * (X / Y)
|
||||
PossiblyExactOperator *Div =
|
||||
cast<PossiblyExactOperator>(Y == Op1 ? Op0 : Op1);
|
||||
if (Div->isExact())
|
||||
return X;
|
||||
}
|
||||
Value *X = 0;
|
||||
if (match(Op0, m_Exact(m_IDiv(m_Value(X), m_Specific(Op1)))) || // (X / Y) * Y
|
||||
match(Op1, m_Exact(m_IDiv(m_Value(X), m_Specific(Op0))))) // Y * (X / Y)
|
||||
return X;
|
||||
|
||||
// i1 mul -> and.
|
||||
if (MaxRecurse && Op0->getType()->isIntegerTy(1))
|
||||
@@ -1162,8 +1158,7 @@ static Value *SimplifyShlInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
|
||||
|
||||
// (X >> A) << A -> X
|
||||
Value *X;
|
||||
if (match(Op0, m_Shr(m_Value(X), m_Specific(Op1))) &&
|
||||
cast<PossiblyExactOperator>(Op0)->isExact())
|
||||
if (match(Op0, m_Exact(m_Shr(m_Value(X), m_Specific(Op1)))))
|
||||
return X;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user