diff options
author | Dan Gohman <gohman@apple.com> | 2009-06-14 22:51:25 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-06-14 22:51:25 +0000 |
commit | 862b7d98d1fc7a96b66b1fca00f5f9e415caced1 (patch) | |
tree | 4903a4f4e7f791e7f94138082bd795223ae068d4 /llvm/lib/Analysis | |
parent | 0652fd59fff428892a3a6622ce1e2daa5e8eb2d1 (diff) | |
download | bcm5719-llvm-862b7d98d1fc7a96b66b1fca00f5f9e415caced1.tar.gz bcm5719-llvm-862b7d98d1fc7a96b66b1fca00f5f9e415caced1.zip |
Do compare constant SCEV values in SCEVComplexityCompare, because
even though the order doesn't matter at the top level of an expression,
it does matter when the constant is a subexpression of an n-ary
expression, because n-ary expressions are sorted lexicographically.
llvm-svn: 73358
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 8357ddbc344..ee077d56b62 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -504,9 +504,18 @@ namespace { return false; } - // Constant sorting doesn't matter since they'll be folded. - if (isa<SCEVConstant>(LHS)) - return false; + // Compare constant values. + if (const SCEVConstant *LC = dyn_cast<SCEVConstant>(LHS)) { + const SCEVConstant *RC = cast<SCEVConstant>(RHS); + return LC->getValue()->getValue().ult(RC->getValue()->getValue()); + } + + // Compare addrec loop depths. + if (const SCEVAddRecExpr *LA = dyn_cast<SCEVAddRecExpr>(LHS)) { + const SCEVAddRecExpr *RA = cast<SCEVAddRecExpr>(RHS); + if (LA->getLoop()->getLoopDepth() != RA->getLoop()->getLoopDepth()) + return LA->getLoop()->getLoopDepth() < RA->getLoop()->getLoopDepth(); + } // Lexicographically compare n-ary expressions. if (const SCEVNAryExpr *LC = dyn_cast<SCEVNAryExpr>(LHS)) { |