<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr">On Sat, Dec 8, 2012 at 5:09 PM, Joerg Sonnenberger <span dir="ltr"><<a href="mailto:joerg@britannica.bec.de" target="_blank">joerg@britannica.bec.de</a>></span> wrote:<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
consider the following input:<br>
<br>
int y;<br>
<br>
void foo(int * restrict x)<br>
{<br>
        if (x == &y)<br>
                (*x)++;<br>
        (*x)++;<br>
}<br>
<br>
The clang codegen gives the argument of foo the noalias attribute and<br>
GVN will optimise the condition to false.<br>
<br>
When discussing this on IRC, Chandler suggested that Clang shouldn't be<br>
creating the noalias attribute here, i.e. do alias interference. I'm not<br>
sure he is correct, but this is subtle enough to warrant some discussion<br>
before filling a PR.<br></blockquote><div><br></div><div style>Sorry, I was wrong. On further consideration, I think Clang is correct here.</div><div style><br></div><div style>1) (*x) is an lvalue based on the pointer 'x' and is modified in the function, so the restrict qualifier actually governs the set of addresses viable...</div>
<div style>2) The expression 'y' is an lvalue expression AFAICT in the C99 standard, is not based on the pointer 'x', and thus cannot access the same object which x points to.</div><div style><br></div><div style>
Thus, clang is correct to optimize the condition to false I think...</div></div></div></div></div>