<div dir="ltr">Hi Eli,<div><br></div><div>Thanks. Do you mean ideally we should extend SimplifyIndVar to do the sdiv->udiv replacement?</div><div><br></div><div>Thanks</div><div>Hongbin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 29, 2017 at 10:59 AM, Friedman, Eli <span dir="ltr"><<a href="mailto:efriedma@codeaurora.org" target="_blank">efriedma@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 3/29/2017 10:35 AM, Hongbin Zheng via llvm-dev wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi llvm-dev,<br>
<br>
Looks like currently ScalarEvolution will give up if there is a sdiv in array subscript, e.g.<br>
<br>
int i;<br>
<br>
A[i * 64 / 2]<br>
<br>
in this case ScalarEvolution will just return an unknown for (i * 64 / 2).<br>
<br>
For this case, InstCombine will do the jobs, but in general, is there a pass to deal with the sdiv here? like replace sdiv by udiv based on the range of "i"?<br>
<br>
</blockquote>
<br></span>
Instcombine will replace sdiv with udiv if it can prove the sign bit is zero, but it isn't very good at analyzing induction variables; we might be able to improve that.<br>
<br>
There are also some related transforms in lib/Transforms/Utils/SimplifyI<wbr>ndVar.cpp.<span class="HOEnZb"><font color="#888888"><br>
<br>
-Eli<br>
<br>
-- <br>
Employee of Qualcomm Innovation Center, Inc.<br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project<br>
<br>
</font></span></blockquote></div><br></div>