diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-10 22:53:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-10 22:53:04 +0000 |
commit | d2265b45ae58c2c26fb12035df1e3900ef37e5b8 (patch) | |
tree | 2d97b40f1282b0566509c19fb788da69f715eb7a /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 91f78080e3727d4472f9aac4b401938ce2195c80 (diff) | |
download | bcm5719-llvm-d2265b45ae58c2c26fb12035df1e3900ef37e5b8.tar.gz bcm5719-llvm-d2265b45ae58c2c26fb12035df1e3900ef37e5b8.zip |
Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe. While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".
llvm-svn: 44817
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 558da230d19..a60a304330e 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -2043,7 +2043,12 @@ static Constant *EvaluateExpression(Value *V, Constant *PHIVal) { if (Operands[i] == 0) return 0; } - return ConstantFoldInstOperands(I, &Operands[0], Operands.size()); + if (const CmpInst *CI = dyn_cast<CmpInst>(I)) + return ConstantFoldCompareInstOperands(CI->getPredicate(), + &Operands[0], Operands.size()); + else + return ConstantFoldInstOperands(I->getOpcode(), I->getType(), + &Operands[0], Operands.size()); } /// getConstantEvolutionLoopExitValue - If we know that the specified Phi is @@ -2213,7 +2218,14 @@ SCEVHandle ScalarEvolutionsImpl::getSCEVAtScope(SCEV *V, const Loop *L) { } } } - Constant *C =ConstantFoldInstOperands(I, &Operands[0], Operands.size()); + + Constant *C; + if (const CmpInst *CI = dyn_cast<CmpInst>(I)) + C = ConstantFoldCompareInstOperands(CI->getPredicate(), + &Operands[0], Operands.size()); + else + C = ConstantFoldInstOperands(I->getOpcode(), I->getType(), + &Operands[0], Operands.size()); return SE.getUnknown(C); } } |