<html><body><p><tt>> </tt><font size="2">I'm not following your example.  If you have two sibling loops with the same parent, one will frequently, but not always dominate the other.  Can you give a specific example of when forming a recurrence between two siblings (without one dominating the other), is useful?  </font><br><br><font size="2">The situation can happen with guarded loops or with a user guard like below:</font><br><br><font size="2">if (c) {<br>  for (i = 0; i < n; i++) <br>    ...<br>}<br>for (j = 0; j < n; j++)<br>  ...</font><br><br><br><font size="2">The specific example that we ran into is described in </font><a href="https://reviews.llvm.org/D75628"><font size="2">https://reviews.llvm.org/D75628</font></a><font size="2">. Basically we have two triangular loops that are siblings and we'd like to run Banerjee MIV tests on the memory accesses in those loops. The loop looks like:</font><br><br><font size="2">void foo(int *restrict A, int n1, int n2, int n3) {<br>  for (int i1 = 0; i1 < n1; i1++) {<br>    for (int i2 = 2; i2 < n2; i2++) {<br>      for (int i3 = i2 + 1; i3 < n3; i3++) {<br>        A[i2 + i3*n2] = 11;<br>      }<br>    }<br>    for (int i4 = 2; i4 < n3; i4++) {<br>      for (int i5 = 1; i5 < i4 - 1; i5++) {<br>        A[i5] = 22;<br>      }<br>    }<br>  }<br>}</font><br><br><font size="2">To check the bounds of the dependence function we need to create a symbolic expression that involves AddRecs for i2 and i4.</font><br><br><font size="2">Bardia Mahjour<br><br></font><br><br><img width="16" height="16" src="cid:1__=8FBB0FA8DFE258A28f9e8a93df938690918c8FB@" border="0" alt="Inactive hide details for Philip Reames ---2020/03/30 02:50:45 PM---On 3/30/20 11:27 AM, Bardia Mahjour via llvm-dev wrote: >"><font size="2" color="#424282">Philip Reames ---2020/03/30 02:50:45 PM---On 3/30/20 11:27 AM, Bardia Mahjour via llvm-dev wrote: ></font><br><br><font size="2" color="#5F5F5F">From:        </font><font size="2">Philip Reames <listmail@philipreames.com></font><br><font size="2" color="#5F5F5F">To:        </font><font size="2">Bardia Mahjour <bmahjour@ca.ibm.com>, LLVM Development List <llvm-dev@lists.llvm.org></font><br><font size="2" color="#5F5F5F">Date:        </font><font size="2">2020/03/30 02:50 PM</font><br><font size="2" color="#5F5F5F">Subject:        </font><font size="2">[EXTERNAL] Re: [llvm-dev] Scalar Evolution Expressions Involving Sibling Loops</font><br><hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br><br><br>
<p>On 3/30/20 11:27 AM, Bardia Mahjour via llvm-dev wrote:
<ul><ul><font size="2">Forwarding to the dev list, in case others ran into similar issues and/or have input on this topic.</font><br><font size="2"><br>Bardia Mahjour</font><br><font size="2" color="#800080"><br>----- Forwarded by Bardia Mahjour/Toronto/IBM on 2020/03/30 02:25 PM -----</font><br><font size="2" color="#5F5F5F"><br>From: </font><font size="2">Bardia Mahjour/Toronto/IBM</font><font size="2" color="#5F5F5F"><br>To: </font><a href="mailto:listmail@philipreames.com"><u><font size="2" color="#0000FF">listmail@philipreames.com</font></u></a><font size="2" color="#5F5F5F"><br>Cc: </font><font size="2">"Michael Kruse" </font><a href="mailto:llvm@meinersbur.de"><u><font size="2" color="#0000FF"><llvm@meinersbur.de></font></u></a><font size="2" color="#5F5F5F"><br>Date: </font><font size="2">2020/03/26 11:47 AM</font><font size="2" color="#5F5F5F"><br>Subject: </font><font size="2">Scalar Evolution Expressions Involving Sibling Loops</font><p><hr width="100%" size="2" align="left" noshade><br><font size="2"><br>Hi Philip,</font><br><font size="2"><br>I hope you are doing well. </font><br><font size="2"><br>We've recently run into an issue with SCEV in the context of dependence analysis, and would like your opinion on it. Background discussion can be found here </font><a href="https://reviews.llvm.org/D75628#inline-689527"><u><font size="2" color="#0000FF">https://reviews.llvm.org/D75628#inline-689527</font></u></a><font size="2">.</font><br><font size="2"><br>Basically in this case, the dependence equation requires us to symbolically create an expression involving two or more recurrences that recur with non-dominating loops (sibling loops). </font></ul></ul><font size="2">I'm not following your example.  If you have two sibling loops with the same parent, one will frequently, but not always dominate the other.  Can you give a specific example of when forming a recurrence between two siblings (without one dominating the other), is useful?  </font><ul><ul><font size="2">Currently creating such a SCEV expression trips asserts in `</font><tt><font size="2">CompareSCEVComplexity</font></tt><font size="2">()` and `</font><tt><font size="2">isKnownViaInduction</font></tt><font size="2">()` saying that a given SCEV expression cannot be composed of recurrences that have no dominance relationship between them. </font><br><font size="2"><br>Michael tried explaining to me why there is this restriction about dominance, and I'm beginning to understand why such restriction may be necessary when evaluating or expanding SCEV expressions in outer scopes (eg. `</font><tt>getSCEVAtScope</tt><font size="2">(nullptr)`) but I still don't understand why this restriction is imposed at construction. Shouldn't this restriction be asserted on when calling getSCEVAtScope instead of when creating AddRecs, given that simplification steps may remove identical terms involving non-dominating loops? </font></ul></ul><font size="2">Well, SCEV construction is generally done to parallel IR.  SSA requires dominance, so having the SCEV operands require dominance would seem like a reasonable thing.  If you want to change this, you'll need to motivate the change.  (i.e. see above question)</font><ul><ul><font size="2"><br>We would appreciate any other insight you might have about this issue.</font><br><font size="2"><br>Regards,</font><br><font size="2"><br>Bardia Mahjour<br>Compiler Optimizations<br>IBM Toronto Software Lab</font><u><font size="2" color="#0000FF"><br></font></u><a href="mailto:bmahjour@ca.ibm.com"><u><font size="2" color="#0000FF">bmahjour@ca.ibm.com</font></u></a><br><br><br><tt>_______________________________________________<br>LLVM Developers mailing list<br></tt><a href="mailto:llvm-dev@lists.llvm.org"><tt><u><font color="#0000FF">llvm-dev@lists.llvm.org</font></u></tt></a><tt><br></tt><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"><tt><u><font color="#0000FF">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</font></u></tt></a><tt><br></tt><br><br></ul></ul><BR>
</body></html>