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: PATCH for bogus loop optimization, part 2



  In message <199807161744.KAA02710@smtp.earthlink.net>you write:
  > BTW, one way to fix this problem, and retain the optimization, might
  > be along the lines of:
  > 
  >   o Pointers can never overflow in a conformant program.  (Neither
  >     can integers, but people do make use of this wrap-around behavior
  >     for integers.)
Right.  And I believe we assume elsewhere in the compiler that a pointer
can not overflow.

  >   o Any comparison between pointers should be unsigned.
I don't think we can assume this though.

  > Thus a fixup pass could go through at the end of loop and replace and
  > signed comparisons of pointers (SYMBOL_REFs, LABEL_REFs, REG's with
  > REGNO_POINTER_FLAG) registers with unsigned comparisons.
Another note, you can't depend on REGNO_POINTER_FLAG catching all pointers.

Consider a pseudo reg which is used in two threads of control, in one thread
it is a pointer, in another it is an integer.  We will not set REGNO_POINTER_FLAG
in this case.  This case can happen due to optimizations which occur before
loop.

There's other cases where you can have a reg which is used in an address,
but does not have REGNO_POINTER_FLAG set.

I'm going to go over your original patch again in a minute :-)

jeff





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