https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90328

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
dr_may_alias_p says a and b cannot alias because:
(gdb) p addr_a->base.u.dependence_info 
$13 = {clique = 2, base = 0}
(gdb) p addr_b->base.u.dependence_info 
$14 = {clique = 2, base = 1}

which comes from
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=260383

So I can simplify the testcase to

void g(int*__restrict x, int*y){*x=*y;}
void f(int* a,int* b){
    for(int i=0;i<1024;++i)
        g(a+i,b+i);
}

and the question becomes: with restrict, is it legal to call g(a+1,a)? I
believe it is, there is a clear example in the C standard that does the same
thing. And restrict is not supposed to imply anything for statements outside of
g. Maybe inlining is supposed to reset something?

I wonder how much optimization we will miss if the alias machinery is changed
to be more conservative on this testcase...

Reply via email to