commit | cefb36c13e506b94c55c53f229b350cc6329d406 | [log] [tgz] |
---|---|---|
author | Chris Lattner <sabre@nondot.org> | Fri May 16 02:59:42 2008 +0000 |
committer | Chris Lattner <sabre@nondot.org> | Fri May 16 02:59:42 2008 +0000 |
tree | fed507f5c323d37b96c0f2e22c411161f71023dd | |
parent | a69bb5619863fd163fcc38466a4e86c235d4b358 [diff] [blame] |
implement PR2328. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51176 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 2f4b192..0f9df27 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3012,6 +3012,10 @@ 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;