diff mbox

Use simplify_gen_binary in canon_rtx

Message ID 87inro3ewx.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Nov. 15, 2016, 4:07 p.m. UTC
After simplifying the operands of a PLUS, canon_rtx checked only
for cases in which one of the simplified operands was a constant,
falling back to gen_rtx_PLUS otherwise.  This left the PLUS in a
non-canonical order if one of the simplified operands was
(plus (reg R1) (const_int X)); we'd end up with:

   (plus (plus (reg R1) (const_int Y)) (reg R2))

rather than:

   (plus (plus (reg R1) (reg R2)) (const_int Y))

Fixing this exposed new DSE opportunities on spu-elf in
gcc.c-torture/execute/builtins/strcat-chk.c but otherwise
it doesn't seem to have much practical effect.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Thanks,
Richard


[ This patch is part of the SVE series posted here:
  https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]

gcc/
2016-11-15  Richard Sandiford  <richard.sandiford@arm.com>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

	* alias.c (canon_rtx): Use simplify_gen_binary.

Comments

Jeff Law Nov. 15, 2016, 4:12 p.m. UTC | #1
On 11/15/2016 09:07 AM, Richard Sandiford wrote:
> After simplifying the operands of a PLUS, canon_rtx checked only
> for cases in which one of the simplified operands was a constant,
> falling back to gen_rtx_PLUS otherwise.  This left the PLUS in a
> non-canonical order if one of the simplified operands was
> (plus (reg R1) (const_int X)); we'd end up with:
>
>    (plus (plus (reg R1) (const_int Y)) (reg R2))
>
> rather than:
>
>    (plus (plus (reg R1) (reg R2)) (const_int Y))
>
> Fixing this exposed new DSE opportunities on spu-elf in
> gcc.c-torture/execute/builtins/strcat-chk.c but otherwise
> it doesn't seem to have much practical effect.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> [ This patch is part of the SVE series posted here:
>   https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]
>
> gcc/
> 2016-11-15  Richard Sandiford  <richard.sandiford@arm.com>
> 	    Alan Hayward  <alan.hayward@arm.com>
> 	    David Sherwood  <david.sherwood@arm.com>
>
> 	* alias.c (canon_rtx): Use simplify_gen_binary.
OK.
jeff
diff mbox

Patch

diff --git a/gcc/alias.c b/gcc/alias.c
index 486d06a..74df23c 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -1800,13 +1800,7 @@  canon_rtx (rtx x)
       rtx x1 = canon_rtx (XEXP (x, 1));
 
       if (x0 != XEXP (x, 0) || x1 != XEXP (x, 1))
-	{
-	  if (CONST_INT_P (x0))
-	    return plus_constant (GET_MODE (x), x1, INTVAL (x0));
-	  else if (CONST_INT_P (x1))
-	    return plus_constant (GET_MODE (x), x0, INTVAL (x1));
-	  return gen_rtx_PLUS (GET_MODE (x), x0, x1);
-	}
+	return simplify_gen_binary (PLUS, GET_MODE (x), x0, x1);
     }
 
   /* This gives us much better alias analysis when called from