proposed patch for gcse.c (delete_null_pointer_checks)

Jeffrey A Law
Sun Oct 31 23:33:00 GMT 1999

  In message < >you write:
  > On Thu, Oct 28, 1999 at 04:53:14AM -0600, Jeffrey A Law wrote:
  > > While the user is not allowed to have a pointer P which points outside of
  >  its
  > > object, but that doesn't stop the compiler from making transformations
  > > in which we generate a pointer P' which points outside of the object then
  > > using P' + Q in memory references.
  > All true, but P' won't appear by itself in an if predicate either.
True, but the pseudo holding P' might appear in the predicate.  Remember, a
pseudo might be set multiple times.  You're looking at this from a level or
two too high.  I agree totally on the language specific stuff which leads
people to believe this is safe -- but at the RTL level, different rules and
assumptions apply.

Assume the if conditional tests (reg 0) against the value zero.

We could have one path to the test in which (reg 0) holds the value zero and
is used in a memory reference as (plus (reg 0) (const_int 10)).  In another
path it might be used as a memory reference as just (reg 0).

Can we optimize the test in that case?  I do not believe so since we can not
absolutely determine at compile time that (reg 0) will or will not value the
value zero at the if statement regardless of which of the two paths we took to
the if statement.

However, there is an optimization we can perform in this case --  in the
path where we used (reg 0) as an address we know which way the if statement
will go -- so we redirect that path (and only that path) to the true or the
false arm of the if statement.  To the best of my knowledge GCC does not
perform this kind of optimization (at least I've seen cases where it should
but did not :-)


More information about the Gcc-patches mailing list