[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jun 25 12:10:01 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.92 -> 1.93
---
Log message:
Instcombine: X * -1 -> -X
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.92 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.93
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.92 Mon Jun 23 16:59:52 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Wed Jun 25 12:09:20 2003
@@ -361,10 +361,11 @@
if (Constant *Op1 = dyn_cast<Constant>(I.getOperand(1))) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
const Type *Ty = CI->getType();
- uint64_t Val = Ty->isSigned() ?
- (uint64_t)cast<ConstantSInt>(CI)->getValue() :
- cast<ConstantUInt>(CI)->getValue();
+ int64_t Val = Ty->isSigned() ? cast<ConstantSInt>(CI)->getValue() :
+ (int64_t)cast<ConstantUInt>(CI)->getValue();
switch (Val) {
+ case -1: // X * -1 -> -X
+ return BinaryOperator::createNeg(Op0, I.getName());
case 0:
return ReplaceInstUsesWith(I, Op1); // Eliminate 'mul double %X, 0'
case 1:
More information about the llvm-commits
mailing list