[PATCH] D40645: [SCEV][NFC] Check NoWrap flags before lexicographical comparison of SCEVs
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 04:15:15 PST 2017
mkazantsev created this revision.
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 eqiovalent SCEVs together and is
not supposed to have any meaningful impact on behavior of any transforms.
https://reviews.llvm.org/D40645
Files:
lib/Analysis/ScalarEvolution.cpp
Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -694,6 +694,10 @@
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, LI, LA->getOperand(i),
@@ -717,6 +721,10 @@
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, LI, LC->getOperand(i),
RC->getOperand(i), DT, Depth + 1);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40645.124911.patch
Type: text/x-patch
Size: 1031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171130/449f8c79/attachment.bin>
More information about the llvm-commits
mailing list