<div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, Sans-Serif;font-size:12px"><div id="yui_3_16_0_1_1417159421155_3591">Hi,</div><div id="yui_3_16_0_1_1417159421155_17580"><br></div><div dir="ltr" id="yui_3_16_0_1_1417159421155_3592">For the program below, where "incr" and "Arr" are globals<br></div><div id="yui_3_16_0_1_1417159421155_8096" dir="ltr">=================================<br></div><div id="yui_3_16_0_1_1417159421155_8095" dir="ltr"><font id="yui_3_16_0_1_1417159421155_11694" face="Courier New, courier, monaco, monospace, sans-serif">int incr;<br style="" class="">float Arr[1000];<br style="" class=""><br style="" class="">int foo ()<br style="" class="">{<br style="" class="">  float x = 0;<br style="" class="">  int newInc = incr+1;<br style="" class="">  for (int i = 0; i < 1000; i++) {<br style="" class="">    for (int j = 0; j < 1000; j += incr) {<br style="" class="">        x += (Arr[i] + Arr[j]);<br style="" class="">    }<br style="" class="">  }<br style="" class="">  retu</font><font id="yui_3_16_0_1_1417159421155_11700" face="Courier New, courier, monaco, monospace, sans-serif">rn x;</font><font face="Courier New, courier, monaco, monospace, sans-serif"><br style="" class="">}</font><br style="" class="">=================================<br></div><div id="yui_3_16_0_1_1417159421155_3549"><br><span></span></div><div id="yui_3_16_0_1_1417159421155_8191" dir="ltr"><span id="yui_3_16_0_1_1417159421155_8190">The SCEV expression computed for the variable "j" is</span></div><div id="yui_3_16_0_1_1417159421155_8192" dir="ltr"><font id="yui_3_16_0_1_1417159421155_11691" face="Courier New, courier, monaco, monospace, sans-serif"><span id="yui_3_16_0_1_1417159421155_11158"> %j.0 = phi i32 [ 0, %for.body ], [ %add8, %for.inc ]<br style="" class="">  -->  %j.0             Exits: <<Unknown>></span></font></div><div id="yui_3_16_0_1_1417159421155_8696" dir="ltr"><span id="yui_3_16_0_1_1417159421155_11157">As is evident, this isn't a useful computation.<br style="" class=""></span></div><div id="yui_3_16_0_1_1417159421155_8697" dir="ltr"><br><span></span></div><div id="yui_3_16_0_1_1417159421155_8306" dir="ltr"><span id="yui_3_16_0_1_1417159421155_8698">Whereas if I use the variable newInc to be the increment for "j", i.e., "j += newInc" in the inner loop, the computed SCEV is</span></div><div id="yui_3_16_0_1_1417159421155_8699" dir="ltr"><span id="yui_3_16_0_1_1417159421155_8708"><font id="yui_3_16_0_1_1417159421155_11683" face="Courier New, courier, monaco, monospace, sans-serif">  %j.0 = phi i32 [ 0, %for.body ], [ %add8, %for.inc ]<br style="" class="">  -->  {0,+,(1 + %0)}<nsw><%for.cond1> </font><br></span></div><div id="yui_3_16_0_1_1417159421155_8701" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8700">where %0 here is a LoadInst for "incr". In this situation, the analysis is working as expected to compute the add-recurrence for "j". <br></span></div><div id="yui_3_16_0_1_1417159421155_8720" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8700"><br></span></div><div id="yui_3_16_0_1_1417159421155_8721" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8700">I would've expected a similar computation for the first case too, something like </span></div><div id="yui_3_16_0_1_1417159421155_8718" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8708"><font id="yui_3_16_0_1_1417159421155_17113" face="Courier New, courier, monaco, monospace, sans-serif">{0,+,%0}<nsw><%for.cond1> </font><br></span></div><div id="yui_3_16_0_1_1417159421155_8717" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8708">Where %0 would be the LoadInst for "incr". </span></div><div id="yui_3_16_0_1_1417159421155_9470" dir="ltr"><br></div><div id="yui_3_16_0_1_1417159421155_9471" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8708">Is this a bug or is there something more involved that causes the deficiency?</span></div><div id="yui_3_16_0_1_1417159421155_9473" dir="ltr"><br><span style="" class="" id="yui_3_16_0_1_1417159421155_8708"></span></div><div id="yui_3_16_0_1_1417159421155_9882" dir="ltr"><span style="" class="" id="yui_3_16_0_1_1417159421155_8708">Thanks,</span></div><div id="yui_3_16_0_1_1417159421155_3546">- Vaivaswatha</div></div>