summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2017-12-06 12:44:56 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2017-12-06 12:44:56 +0000
commitd4f5987c5895ee36fbac586f1f9be428a54f7099 (patch)
treec26a3fdaab7790019f6d1599de919362729e4631 /llvm/lib/Analysis
parent515f42cbaab3597d17d0e4bc16c05b4837c727a8 (diff)
downloadbcm5719-llvm-d4f5987c5895ee36fbac586f1f9be428a54f7099.tar.gz
bcm5719-llvm-d4f5987c5895ee36fbac586f1f9be428a54f7099.zip
[SCEV][NFC] Check NoWrap flags before lexicographical comparison of SCEVs
Lexicographical comparison of SCEV trees is potentially expensive for big expression trees. We can define ordering between them for AddRecs and N-ary operations by SCEV NoWrap flags to make non-equality check cheaper. This change does not prevent grouping eqivalent SCEVs together and is not supposed to have any meaningful impact on behavior of any transforms. Reviewed By: sanjoy Differential Revision: https://reviews.llvm.org/D40645 llvm-svn: 319889
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 48c08b3e10f..9bc8f2dc83d 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -694,6 +694,10 @@ static int CompareSCEVComplexity(
if (LNumOps != RNumOps)
return (int)LNumOps - (int)RNumOps;
+ // Compare NoWrap flags.
+ if (LA->getNoWrapFlags() != RA->getNoWrapFlags())
+ return (int)LA->getNoWrapFlags() - (int)RA->getNoWrapFlags();
+
// Lexicographically compare.
for (unsigned i = 0; i != LNumOps; ++i) {
int X = CompareSCEVComplexity(EqCacheSCEV, EqCacheValue, LI,
@@ -718,6 +722,10 @@ static int CompareSCEVComplexity(
if (LNumOps != RNumOps)
return (int)LNumOps - (int)RNumOps;
+ // Compare NoWrap flags.
+ if (LC->getNoWrapFlags() != RC->getNoWrapFlags())
+ return (int)LC->getNoWrapFlags() - (int)RC->getNoWrapFlags();
+
for (unsigned i = 0; i != LNumOps; ++i) {
int X = CompareSCEVComplexity(EqCacheSCEV, EqCacheValue, LI,
LC->getOperand(i), RC->getOperand(i), DT,
OpenPOWER on IntegriCloud