<div dir="ltr"><div>Yes, the full test case is:</div><div><br></div><div>static int x = 100;</div><div>int y = whatever;</div><div><br></div><div>int main() {</div><div>   x = -101;</div><div>   y = whatever that's not whatever above;</div><div>   printf("%d\n", y);</div><div>   printf("%d\n", x);</div><div>  return 0;</div><div>}</div><div><br></div><div>You are correct, in the above test case the globalopt does not make the transformation.... however, I think the original issue still stands, it really shouldn't be doing it here either.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 30, 2016 at 5:52 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On Aug 30, 2016, at 1:01 PM, Ryan Taylor via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
</span><span>> Given some code:<br>
><br>
> static int x = 100;<br>
><br>
> int main() {<br>
>    x = 101;<br>
>    printf("%d\n", x);<br>
> }<br>
><br>
> results in:<br>
><br>
> %0 = load i1<br>
> %1 = select %0, 101, 100<br>
<br>
</span>If x is only touched in one function, I’d expect globlaopt to turn it into an alloca instead of leaving it global and shrinking it.<br>
Did you oversimplify the real case where you see this for the sake of the example here?<br>
<br>
—<br>
Mehdi<br>
<span><br>
<br>
> ...<br>
> ...<br>
><br>
> 1) What architecture(s) does this benefit?<br>
> 2) What's the best way to circumvent this in the backend (currently I am just not allowing this opt function to run)? I have tried a few setOperationAction methods to no result. Rather not just comment out core code because it makes porting more difficult.<br>
><br>
> -Ryan<br>
</span>> ______________________________<wbr>_________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank" rel="noreferrer">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br>
</blockquote></div><br></div>