[PATCH] D47087: [ScopHelper] Cache ScopExpander results.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 27 13:39:53 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL335783: [ScopHelper] Cache ScopExpander results. (authored by efriedma, committed by ).
Herald added a reviewer: bollu.
Changed prior to commit:
https://reviews.llvm.org/D47087?vs=147585&id=153167#toc
Repository:
rL LLVM
https://reviews.llvm.org/D47087
Files:
polly/trunk/lib/Support/ScopHelper.cpp
Index: polly/trunk/lib/Support/ScopHelper.cpp
===================================================================
--- polly/trunk/lib/Support/ScopHelper.cpp
+++ polly/trunk/lib/Support/ScopHelper.cpp
@@ -249,13 +249,25 @@
return Expander.expandCodeFor(E, Ty, I);
}
+ const SCEV *visit(const SCEV *E) {
+ // Cache the expansion results for intermediate SCEV expressions. A SCEV
+ // expression can refer to an operand multiple times (e.g. "x*x), so
+ // a naive visitor takes exponential time.
+ if (SCEVCache.count(E))
+ return SCEVCache[E];
+ const SCEV *Result = SCEVVisitor::visit(E);
+ SCEVCache[E] = Result;
+ return Result;
+ }
+
private:
SCEVExpander Expander;
ScalarEvolution &SE;
const char *Name;
const Region &R;
ValueMapT *VMap;
BasicBlock *RTCBB;
+ DenseMap<const SCEV *, const SCEV *> SCEVCache;
const SCEV *visitGenericInst(const SCEVUnknown *E, Instruction *Inst,
Instruction *IP) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47087.153167.patch
Type: text/x-patch
Size: 994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180627/a4d16eaf/attachment.bin>
More information about the llvm-commits
mailing list