aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 505313ba9c..696575e3d6 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -361,10 +361,11 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
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: