implement PR2328.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51176 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2008-05-16 02:59:42 +00:00
parent e44b1bd3dc
commit b2ae9e34db
2 changed files with 16 additions and 2 deletions

View File

@@ -3012,6 +3012,10 @@ Instruction *InstCombiner::commonDivTransforms(BinaryOperator &I) {
Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) {
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
// (sdiv X, X) --> 1 (udiv X, X) --> 1
if (Op0 == Op1)
return ReplaceInstUsesWith(I, ConstantInt::get(I.getType(), 1));
if (Instruction *Common = commonDivTransforms(I))
return Common;