summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SCCP.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-05-06 03:01:37 +0000
committerChris Lattner <sabre@nondot.org>2002-05-06 03:01:37 +0000
commit940daedc223f4c0de664ec5379bba01c0975326c (patch)
tree5a59a611e9fa948de39f483f0825f70c735e7dda /llvm/lib/Transforms/Scalar/SCCP.cpp
parent6670d86b0bd9938d2d500411869f26a757304596 (diff)
downloadbcm5719-llvm-940daedc223f4c0de664ec5379bba01c0975326c.tar.gz
bcm5719-llvm-940daedc223f4c0de664ec5379bba01c0975326c.zip
Implement constant propogation of shift instructions
llvm-svn: 2471
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SCCP.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SCCP.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 8d1547577b4..015c67a0d22 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -502,9 +502,15 @@ void SCCP::visitBinaryOperator(Instruction *I) {
if (V1State.isOverdefined() || V2State.isOverdefined()) {
markOverdefined(I);
} else if (V1State.isConstant() && V2State.isConstant()) {
- Constant *Result = ConstantFoldBinaryInstruction(I->getOpcode(),
- V1State.getConstant(),
- V2State.getConstant());
+ Constant *Result = 0;
+ if (isa<BinaryOperator>(I))
+ Result = ConstantFoldBinaryInstruction(I->getOpcode(),
+ V1State.getConstant(),
+ V2State.getConstant());
+ else if (isa<ShiftInst>(I))
+ Result = ConstantFoldShiftInstruction(I->getOpcode(),
+ V1State.getConstant(),
+ V2State.getConstant());
if (Result)
markConstant(I, Result); // This instruction constant folds!
else
OpenPOWER on IntegriCloud