summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-12-21 14:00:22 +0000
committerDuncan Sands <baldrick@free.fr>2010-12-21 14:00:22 +0000
commitd0eb6d39f81eb7cbe6c62bd3be1a7e85b02cab91 (patch)
tree63bc11d152a86c3d9701733fbea6b3597d8266e7 /llvm/lib/Transforms
parent07c17132d7b7e8953a25e472f7e82dc60763e523 (diff)
downloadbcm5719-llvm-d0eb6d39f81eb7cbe6c62bd3be1a7e85b02cab91.tar.gz
bcm5719-llvm-d0eb6d39f81eb7cbe6c62bd3be1a7e85b02cab91.zip
Pull a few more simplifications out of instcombine (there are still
plenty left though!), in particular for multiplication. llvm-svn: 122330
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 6bce6a2ed1d..a2fe0cf659e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -14,6 +14,7 @@
#include "InstCombine.h"
#include "llvm/IntrinsicInst.h"
+#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Support/PatternMatch.h"
using namespace llvm;
using namespace PatternMatch;
@@ -50,8 +51,8 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
bool Changed = SimplifyAssociativeOrCommutative(I);
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
- if (isa<UndefValue>(Op1)) // undef * X -> 0
- return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
+ if (Value *V = SimplifyMulInst(Op0, Op1, TD))
+ return ReplaceInstUsesWith(I, V);
// Simplify mul instructions with a constant RHS.
if (Constant *Op1C = dyn_cast<Constant>(Op1)) {
@@ -64,10 +65,6 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
return BinaryOperator::CreateMul(SI->getOperand(0),
ConstantExpr::getShl(CI, ShOp));
- if (CI->isZero())
- return ReplaceInstUsesWith(I, Op1C); // 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());
OpenPOWER on IntegriCloud