aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-10 22:53:04 +0000
committerChris Lattner <sabre@nondot.org>2007-12-10 22:53:04 +0000
commitd6e569110ab0ff7846c184f1c92effd798ff39a8 (patch)
tree400c56bd0a897bc94b6b69e53505a2d1074cdb57 /lib/Analysis/ScalarEvolution.cpp
parent844fad5f440c7a69112c2f8f17bbc488232a6893 (diff)
downloadexternal_llvm-d6e569110ab0ff7846c184f1c92effd798ff39a8.tar.gz
external_llvm-d6e569110ab0ff7846c184f1c92effd798ff39a8.tar.bz2
external_llvm-d6e569110ab0ff7846c184f1c92effd798ff39a8.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". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 558da230d1..a60a304330 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/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);
}
}