[patch tree-optimization]: Improve handling of conditional-branches on targets with high branch costs

Michael Matz matz@suse.de
Wed Oct 26 15:15:00 GMT 2011


Hi,

On Wed, 26 Oct 2011, Kai Tietz wrote:

> well, if such a function is used as inline and we know for it that j has 
> value != 2, then we have here a big difference.  For your first example, 
> we still have to do the memory access to *i, even if we are not 
> interested in result.

Actually we don't have to preserve memory accesses.  The interesting case 
is if the pointer has an invalid value.  The behaviour of the access then 
is undefined, and it's okay to not do it at all.  In case the pointer does 
point to an object the access (if it's value isn't needed) also isn't 
necessary.  IOW: in "void f(int *p) { int i = *p; }" we can always remove 
the pointer read.  So, I still maintain that the transformation on the 
original example was okay.


Ciao,
Michael.



More information about the Gcc-patches mailing list