This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: proposed patch for gcse.c (delete_null_pointer_checks)


  In message <38181E10.9C5BCA18@acm.org>you write:
  > Erm, forgive me for jumping in here, but I beleive you can determine that
  > in any expression of the form *(ptr + off), that ptr can't be null via that
  > code path. If it were null you've just invoked undefined effects.
No need to apologize -- this kind of input is what makes GCC development
successful.


I agree with your reading of the standard.  But you're missing one critical
issue.  The value in a register does not necessarily have to be a pointer
as defined by language standards.

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.

In fact, these transformations are absolutely necessary to generate code
on some architectures.  In other cases the compiler does these kinds of
transformations to improve array accesses in loops.

--


I've long held the belief that we should refine REGNO_POINTER_FLAG to
indicate that a register is a pure pointer (right now it can be set for
a derived pointer such as P').

Given that change we could check REGNO_POINTER_FLAG for pseudos and apply
the optimization for memory references which use a pure pointer plus an
offset.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]