[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Sep 11 17:26:01 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.118 -> 1.119
---
Log message:
Simplify code
Implement InstCombine/mul.ll:test9
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.118 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.119
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.118 Wed Sep 10 00:29:03 2003
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Thu Sep 11 17:24:54 2003
@@ -527,17 +527,14 @@
return BinaryOperator::create(Instruction::Mul, SI->getOperand(0),
*CI << *ShOp);
- const Type *Ty = CI->getType();
- int64_t Val = (int64_t)cast<ConstantInt>(CI)->getRawValue();
- switch (Val) {
- case -1: // X * -1 -> -X
+ if (CI->isNullValue())
+ return ReplaceInstUsesWith(I, Op1); // X * 0 == 0
+ if (CI->equalsInt(1)) // X * 1 == X
+ return ReplaceInstUsesWith(I, Op0);
+ if (CI->isAllOnesValue()) // X * -1 == 0 - X
return BinaryOperator::createNeg(Op0, I.getName());
- case 0:
- return ReplaceInstUsesWith(I, Op1); // Eliminate 'mul double %X, 0'
- case 1:
- return ReplaceInstUsesWith(I, Op0); // Eliminate 'mul int %X, 1'
- }
+ int64_t Val = (int64_t)cast<ConstantInt>(CI)->getRawValue();
if (uint64_t C = Log2(Val)) // Replace X*(2^C) with X << C
return new ShiftInst(Instruction::Shl, Op0,
ConstantUInt::get(Type::UByteTy, C));
More information about the llvm-commits
mailing list