[PATCH] fix prefetch optimization in loop.c

Janis Johnson janis187@us.ibm.com
Mon Jan 21 16:29:00 GMT 2002


On Mon, Jan 21, 2002 at 04:20:47PM -0800, Richard Henderson wrote:
> On Mon, Jan 21, 2002 at 11:11:14AM -0800, Janis Johnson wrote:
> > This patch allows the mainline to bootstrap on i686-pc-linux-gnu with
> > BOOT_CFLAGS="-O2 -fprefetch-loop-arrays -mcpu=pentium3".  Without this
> > patch, reload.c and reload1.c were being miscompiled when loops were
> > considered and then rejected for prefetch optimization.  This happened
> > because of an assumption that rtx_copy was returning a copy of the
> > address rtx when it was actually returning a pointer to the original
> > rtx.
> 
> Um, the only cases in which a copy is not created is bare
> registers and bare constants.  Why would this cause a problem?

This is the code in copy_rtx() that causes the problem:

    case CONST:
      /* CONST can be shared if it contains a SYMBOL_REF.  If it contains
         a LABEL_REF, it isn't sharable.  */
      if (GET_CODE (XEXP (orig, 0)) == PLUS
          && GET_CODE (XEXP (XEXP (orig, 0), 0)) == SYMBOL_REF
          && GET_CODE (XEXP (XEXP (orig, 0), 1)) == CONST_INT)
        return orig;
      break;

emit_prefetch_instructions() was pulling out the CONST_INT and
combining it with other index values, but if it decided not to generate
a prefetch, the original rtx was changed with no good way to put it
back the way it was.

Removing this code in copy_rtx() also fixes the problem, if you think
that's the right thing to do.

Janis



More information about the Gcc-patches mailing list