diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2008-01-22 05:08:48 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2008-01-22 05:08:48 +0000 |
| commit | e6b0c0036a64f4be4646230f2510e5b20dc04351 (patch) | |
| tree | cefef13ba59c18f82fbf81f47cc36144ad140052 /lib/Transforms | |
| parent | 18bef16d84748bb012a4506ef3c76e26cfba1c68 (diff) | |
| download | external_llvm-e6b0c0036a64f4be4646230f2510e5b20dc04351.zip external_llvm-e6b0c0036a64f4be4646230f2510e5b20dc04351.tar.gz external_llvm-e6b0c0036a64f4be4646230f2510e5b20dc04351.tar.bz2 | |
Multiply can be evaluated in a different type, so long as the target type has
a smaller bitwidth.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46244 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
| -rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 2ad592a..3e009eb 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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: |
