summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-01-22 05:08:48 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-01-22 05:08:48 +0000
commit78712e5b5905dbf6a01d7a9ba660fd8c984ab782 (patch)
tree3d196e2cec0eaab69ca5b5a29be39325e2faa06d /llvm/lib/Transforms
parent1dea406e73983745be06cd6c1c00a2db030e5d0f (diff)
downloadbcm5719-llvm-78712e5b5905dbf6a01d7a9ba660fd8c984ab782.tar.gz
bcm5719-llvm-78712e5b5905dbf6a01d7a9ba660fd8c984ab782.zip
Multiply can be evaluated in a different type, so long as the target type has
a smaller bitwidth. llvm-svn: 46244
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 2ad592a8f11..3e009ebce46 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -6512,6 +6512,15 @@ static bool CanEvaluateInDifferentType(Value *V, const IntegerType *Ty,
CanEvaluateInDifferentType(I->getOperand(1), Ty, CastOpc,
NumCastsRemoved);
+ case Instruction::Mul:
+ break;
+ // A multiply can be truncated by truncating its operands.
+ return Ty->getBitWidth() < OrigTy->getBitWidth() &&
+ CanEvaluateInDifferentType(I->getOperand(0), Ty, CastOpc,
+ NumCastsRemoved) &&
+ CanEvaluateInDifferentType(I->getOperand(1), Ty, CastOpc,
+ NumCastsRemoved);
+
case Instruction::Shl:
// If we are truncating the result of this SHL, and if it's a shift of a
// constant amount, we can always perform a SHL in a smaller type.
@@ -6571,6 +6580,7 @@ Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty,
switch (I->getOpcode()) {
case Instruction::Add:
case Instruction::Sub:
+ case Instruction::Mul:
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
OpenPOWER on IntegriCloud