[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Apr 26 09:02:03 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.192 -> 1.193
---
Log message:
Instcombine X/-1 --> 0-X
---
Diffs of the changes: (+5 -1)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.192 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.193
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.192 Sat Apr 17 13:16:10 2004
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Apr 26 09:01:59 2004
@@ -849,10 +849,14 @@
}
Instruction *InstCombiner::visitDiv(BinaryOperator &I) {
- // div X, 1 == X
if (ConstantInt *RHS = dyn_cast<ConstantInt>(I.getOperand(1))) {
+ // div X, 1 == X
if (RHS->equalsInt(1))
return ReplaceInstUsesWith(I, I.getOperand(0));
+
+ // div X, -1 == -X
+ if (RHS->isAllOnesValue())
+ return BinaryOperator::createNeg(I.getOperand(0));
// Check to see if this is an unsigned division with an exact power of 2,
// if so, convert to a right shift.
More information about the llvm-commits
mailing list