<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jul 16, 2013, at 9:27 AM, Nadav Rotem <<a href="mailto:nrotem@apple.com">nrotem@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi Hal, </div><div><br></div><div>Yes, we can do better.  Andy suggested that we calculate the offsets of the stores from the base pointer and sort them according to this offset. Like you said, that will bring us down to NlogN. </div></div></blockquote><div dir="auto"><br></div>Also you’ll want to compare gep offsets directly (via accumulateConstantOffset) instead of creating very expensive SCEV expressions. Then</div><div>if isConsecutiveAccess was the only use of SCEV, you can remove the dependence entirely. SCEV is mostly useful in loop passes.</div><div><br></div><div>-Andy</div><div dir="auto"><br></div><div dir="auto"><br><blockquote type="cite"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><div><div>On Jul 16, 2013, at 9:13 AM, Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">----- Original Message -----<br><blockquote type="cite">Author: nadav<br>Date: Tue Jul 16 10:25:17 2013<br>New Revision: 186420<br><br>URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=186420&view=rev">http://llvm.org/viewvc/llvm-project?rev=186420&view=rev</a><br>Log:<br>SLPVectorizer: Reduce the compile time of the consecutive store<br>lookup.<br><br>Process groups of stores in chunks of 16.<br></blockquote><br>This is, in practice, what the BB vectorizer does (uses a cutoff on what is otherwise a quadratic search), and while I think that some cutoff is definitely necessary, I've never liked the solution. Is there any way that we could sort them first? That way the sorting would be NlogN and we could handle larger groups?<br><br>Thanks again,<br>Hal<br><br><blockquote type="cite"><br><br>Modified:<br>   llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp<br><br>Modified: llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp<br>URL:<br><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=186420&r1=186419&r2=186420&view=diff">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp?rev=186420&r1=186419&r2=186420&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp (original)<br>+++ llvm/trunk/lib/Transforms/Vectorize/SLPVectorizer.cpp Tue Jul 16<br>10:25:17 2013<br>@@ -1645,7 +1645,7 @@ bool SLPVectorizer::vectorizeStoreChain(<br>}<br><br>bool SLPVectorizer::vectorizeStores(ArrayRef<StoreInst *> Stores,<br>-                                      int costThreshold, BoUpSLP &R)<br>{<br>+                                    int costThreshold, BoUpSLP &R) {<br>  SetVector<Value *> Heads, Tails;<br>  SmallDenseMap<Value *, Value *> ConsecutiveChain;<br><br>@@ -1656,9 +1656,11 @@ bool SLPVectorizer::vectorizeStores(Arra<br><br>  // Do a quadratic search on all of the given stores and find<br>  // all of the pairs of stores that follow each other.<br>-  for (unsigned i = 0, e = Stores.size(); i < e; ++i)<br>+  for (unsigned i = 0, e = Stores.size(); i < e; ++i) {<br>+    if (Heads.count(Stores[i]))<br>+      continue;<br>    for (unsigned j = 0; j < e; ++j) {<br>-      if (i == j)<br>+      if (i == j || Tails.count(Stores[j]))<br>        continue;<br><br>      if (R.isConsecutiveAccess(Stores[i], Stores[j])) {<br>@@ -1667,6 +1669,7 @@ bool SLPVectorizer::vectorizeStores(Arra<br>        ConsecutiveChain[Stores[i]] = Stores[j];<br>      }<br>    }<br>+  }<br><br>  // For stores that start but don't end a link in the chain:<br>  for (SetVector<Value *>::iterator it = Heads.begin(), e =<br>  Heads.end();<br>@@ -1879,9 +1882,14 @@ bool SLPVectorizer::vectorizeStoreChains<br>      continue;<br><br>    DEBUG(dbgs() << "SLP: Analyzing a store chain of length "<br>-                 << it->second.size() << ".\n");<br>+          << it->second.size() << ".\n");<br><br>-    Changed |= vectorizeStores(it->second, -SLPCostThreshold, R);<br>+    // Process the stores in chunks of 16.<br>+    for (unsigned CI = 0, CE = it->second.size(); CI < CE; CI+=16) {<br>+      unsigned Len = std::min<unsigned>(CE - CI, 16);<br>+      ArrayRef<StoreInst *> Chunk(&it->second[CI], Len);<br>+      Changed |= vectorizeStores(Chunk, -SLPCostThreshold, R);<br>+    }<br>  }<br>  return Changed;<br>}<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br><br></blockquote><br>--<span class="Apple-converted-space"> </span><br>Hal Finkel<br>Assistant Computational Scientist<br>Leadership Computing Facility<br>Argonne National Laboratory</div></blockquote></div><br></div>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</div></blockquote></div><br></body></html>