Patchwork [PATCH/MIPS] Fix mips_get_unaligned_mem in some cases

login
register
mail settings
Submitter Andrew Pinski
Date July 21, 2012, 7:36 a.m.
Message ID <CA+=Sn1myL8rx7Gsu8BfgytJ-2iQDQS3+WUuSgLvq136o9qwNMg@mail.gmail.com>
Download mbox | patch
Permalink /patch/172406/
State New
Headers show

Comments

Andrew Pinski - July 21, 2012, 7:36 a.m.
Hi,
  The problem here is that adjust_address returns the same rtl as we
already have a BLKmode; mips_block_move_straight pass a BLKmode MEM to
mips_expand_ext_as_unaligned_load.
The following patch fixes the problem by copying the MEM after calling
adjust_address.  This does increase garbage slightly but not enough to
take a notice.  I could only get this to expose after improving
mips_block_move_straight but it could show up in otherwise.  The
testcase where it showed has already been committed as
testsuite/gcc.c-torture/compile/20120524-1.c .

OK?  Bootstrapped and tested on mips64-linux-gnu with no regressions.

ChangeLog:
* config/mips/mips.c (mips_get_unaligned_mem): Copy *op after calling
adjust_address.
Richard Sandiford - July 21, 2012, 8:15 a.m.
Andrew Pinski <pinskia@gmail.com> writes:
>   The problem here is that adjust_address returns the same rtl as we
> already have a BLKmode; mips_block_move_straight pass a BLKmode MEM to
> mips_expand_ext_as_unaligned_load.
> The following patch fixes the problem by copying the MEM after calling
> adjust_address.  This does increase garbage slightly but not enough to
> take a notice.  I could only get this to expose after improving
> mips_block_move_straight but it could show up in otherwise.  The
> testcase where it showed has already been committed as
> testsuite/gcc.c-torture/compile/20120524-1.c .
>
> OK?  Bootstrapped and tested on mips64-linux-gnu with no regressions.
>
> ChangeLog:
> * config/mips/mips.c (mips_get_unaligned_mem): Copy *op after calling
> adjust_address.
>
> Index: config/mips/mips.c
> ===================================================================
> --- config/mips/mips.c	(revision 189542)
> +++ config/mips/mips.c	(working copy)
> @@ -7220,6 +7220,8 @@ mips_get_unaligned_mem (rtx *op, HOST_WI
>    /* Adjust *OP to refer to the whole field.  This also has the effect
>       of legitimizing *OP's address for BLKmode, possibly simplifying it.  */
>    *op = adjust_address (*op, BLKmode, 0);
> +  /*  Copy the RTX as adjust_address might return the original rtl. */
> +  *op = copy_rtx (*op);

Sorry to be so picky, but I'd prefer:

  /* Create a copy of *OP that refers to the whole field.  This also has
     the effect of legitimizing *OP's address for BLKmode, possibly
     simplifying it.  */
  *op = copy_rtx (adjust_address (*op, BLKmode, 0));

OK with that change, thanks.

Richard

Patch

Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c	(revision 189542)
+++ config/mips/mips.c	(working copy)
@@ -7220,6 +7220,8 @@  mips_get_unaligned_mem (rtx *op, HOST_WI
   /* Adjust *OP to refer to the whole field.  This also has the effect
      of legitimizing *OP's address for BLKmode, possibly simplifying it.  */
   *op = adjust_address (*op, BLKmode, 0);
+  /*  Copy the RTX as adjust_address might return the original rtl. */
+  *op = copy_rtx (*op);
   set_mem_size (*op, width / BITS_PER_UNIT);
 
   /* Get references to both ends of the field.  We deliberately don't