Hi Sanjoy & Hal,<br><br>Looking at LoopDependenceAnalysis::analyzeZIV ...<br>I don't understand much about SCEV, but the code seems inadequate.<br>Consider these three examples:<div><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px">
<div><font face="'courier new', monospace">int a = ...; // we can't be sure of the relationship between a and b</font></div><div><font face="'courier new', monospace">int b = ...; // perhaps they are parameters, or the result of I/O</font></div>
<div><font face="'courier new', monospace"><br></font></div><div><font face="'courier new', monospace">for (int i = 0; i < n; i++) {</font></div><div><font face="'courier new', monospace">  v[a][i] = ...;</font></div>
<div><font face="'courier new', monospace">  v[a + 1][i] = ...;</font></div><div><span style="font-family:'courier new',monospace">}</span></div><div><span style="font-family:'courier new',monospace"><br>
</span></div><div><span style="font-family:'courier new',monospace">for (int i = 0; i < n; i++) {</span></div><div><span style="font-family:'courier new',monospace">  v[a][i] = ...;</span></div><div><span style="font-family:'courier new',monospace">  v[a][i] = ...;</span></div>
<div><span style="font-family:'courier new',monospace">}</span></div><div><span style="font-family:'courier new',monospace"><br></span></div><div><span style="font-family:'courier new',monospace">for (int i = 0; i < n; i++) {</span></div>
<div><span style="font-family:'courier new',monospace">  v[a][i] = ...;</span></div><div><span style="font-family:'courier new',monospace">  v[b][i] = ...;</span></div><div><span style="font-family:'courier new',monospace">}</span></div>
</blockquote><font face="'courier new', monospace"><br></font><div>In the first loop, we can be confident that the two stores are to different locations and there is no dependence.</div><div><br></div><div>In the second loop, we can be sure that the two references are to the same location and that there's a consistent loop-independent output dependence between the two stores.</div>
<div><br></div><div>In the third loop, we can't be sure what's going on and must therefore assume an inconsistent loop-independent output dependence.</div></div><div><br></div><div>The ZIVanalysis code doesn't do the right thing.  I believe, but am not certain, that it will get the 1st two loops right, but will return Independent for the 3rd case. Better code might look something like:</div>
<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="'courier new', monospace">SCEV *delta = a - b</font></div><div><font face="'courier new', monospace">if (delta is zero) {</font></div>
<div><font face="'courier new', monospace">  consistant &= true</font></div><div><font face="'courier new', monospace">  return Dependent</font></div><div><font face="'courier new', monospace">}</font></div>
<div><font face="'courier new', monospace">else if (delta is a known constant)</font></div><div><font face="'courier new', monospace">  return Independent</font></div><div><font face="'courier new', monospace">}</font></div>
<div><font face="'courier new', monospace">else { // delta is some symbolic term</font></div><div><font face="'courier new', monospace">  consistent = false</font></div><div><font face="'courier new', monospace">  return Dependent</font></div>
<div><font face="'courier new', monospace">}</font></div></blockquote><div><br></div><div>By the way, when I assert all these things about dependence analysis, I'm not always correct. If you disagree, please let me know and we'll discuss it.</div>
<div><br></div><div>Thanks,</div><div>Preston</div><div><br></div>