Implemented constant propogation of cast instructions
llvm-svn: 1064
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 101e892..70d52a6 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -442,9 +442,10 @@
if (VState.isOverdefined()) { // Inherit overdefinedness of operand
markOverdefined(I);
} else if (VState.isConstant()) { // Propogate constant value
- ConstPoolVal *Result =
- opt::ConstantFoldUnaryInstruction(I->getOpcode(),
- VState.getConstant());
+ ConstPoolVal *Result = isa<CastInst>(I)
+ ? opt::ConstantFoldCastInstruction(VState.getConstant(), I->getType())
+ : opt::ConstantFoldUnaryInstruction(I->getOpcode(),
+ VState.getConstant());
if (Result) {
// This instruction constant folds!