one more instcombine variant that is needed to work with future changes,

no functionality change currently.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123517 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2011-01-15 05:50:18 +00:00
parent 27a98482bd
commit 67920320b2

View File

@ -672,6 +672,15 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
Value *NewMul = Builder->CreateMul(A, B);
return BinaryOperator::CreateAdd(Op0, NewMul);
}
// X - A*Cst -> X + A*-Cst
// X - Cst*A -> X + A*-Cst
ConstantInt *BCst;
if (match(Op1I, m_Mul(m_Value(A), m_ConstantInt(BCst))) ||
match(Op1I, m_Mul(m_ConstantInt(BCst), m_Value(A)))) {
Value *NewMul = Builder->CreateMul(A, ConstantExpr::getNeg(BCst));
return BinaryOperator::CreateAdd(Op0, NewMul);
}
}
}