On Sun, 12 May 2019, Marc Glisse wrote:

this patch lets gcc know that if a pointer existed before the call to malloc, the result of malloc cannot alias it. This is a bit ad hoc and fragile. A small improvement would be, when the 2 statements are in the same bb but in the wrong order, to check if there is any statement in between that might prevent from reordering them. But that's more complicated, and the patch as it is already does help.

I was also thinking of adding a few more cases:

* if ptr1=PHI<x,y> and ptr2 can alias neither x nor y... but we probably need to be careful to avoid a combinatorial explosion.

* if ptr1 is a NULL pointer, we cannot dereference it (at least with the right flags), so dereferencing it cannot alias anything. This seems mostly useful as a recursive call with PHI<x,0>.

Let me know if this looks like a bad idea.

--
Marc Glisse

Reply via email to