[InstCombine] make pattern matching more consistent; NFC

We could go either way on this and several similar matches.
Just matching as a binop is possibly slightly more efficient;
we don't need to re-confirm the opcode of the instruction.
This commit is contained in:
Sanjay Patel 2022-06-02 13:03:37 -04:00
parent 986e5dedf2
commit 8689463bfb
1 changed files with 4 additions and 4 deletions

View File

@ -384,7 +384,7 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
// TODO: We are not checking one-use because the elimination of the multiply
// is better for analysis?
const APInt *C;
if (match(&I, m_c_Mul(m_LShr(m_Value(X), m_APInt(C)), m_Value(Y))) &&
if (match(&I, m_c_BinOp(m_LShr(m_Value(X), m_APInt(C)), m_Value(Y))) &&
*C == C->getBitWidth() - 1) {
Value *IsNeg = Builder.CreateIsNeg(X, "isneg");
return SelectInst::Create(IsNeg, Y, ConstantInt::getNullValue(Ty));
@ -393,9 +393,9 @@ Instruction *InstCombinerImpl::visitMul(BinaryOperator &I) {
// ((ashr X, 31) | 1) * X --> abs(X)
// X * ((ashr X, 31) | 1) --> abs(X)
if (match(&I, m_c_BinOp(m_Or(m_AShr(m_Value(X),
m_SpecificIntAllowUndef(BitWidth - 1)),
m_One()),
m_Deferred(X)))) {
m_SpecificIntAllowUndef(BitWidth - 1)),
m_One()),
m_Deferred(X)))) {
Value *Abs = Builder.CreateBinaryIntrinsic(
Intrinsic::abs, X,
ConstantInt::getBool(I.getContext(), I.hasNoSignedWrap()));