Patchwork RFA: Generate canonical rtl in process_address

login
register
mail settings
Submitter Richard Sandiford
Date Oct. 25, 2012, 9:50 a.m.
Message ID <87625ynann.fsf@talisman.home>
Download mbox | patch
Permalink /patch/194093/
State New
Headers show

Comments

Richard Sandiford - Oct. 25, 2012, 9:50 a.m.
Hi Vlad,

As promised a while ago, here's a patch to make process_address
create canonical rtl.  It also fixes the base_reg_class for the
index + disp => base + index case.

Tested on x86_64-linux-gnu.  Also tested by making sure that there
were no changes in assembly output for a set of gcc .ii files
OK to install?

Richard


gcc/
	* lra-constraints.c (process_address): Tighten arguments to
	base_reg_class.  Use simplify_gen_binary to generate PLUS rtxes.
Vladimir Makarov - Oct. 25, 2012, 7:46 p.m.
On 10/25/2012 05:50 AM, Richard Sandiford wrote:
> Hi Vlad,
>
> As promised a while ago, here's a patch to make process_address
> create canonical rtl.  It also fixes the base_reg_class for the
> index + disp => base + index case.
>
> Tested on x86_64-linux-gnu.  Also tested by making sure that there
> were no changes in assembly output for a set of gcc .ii files
> OK to install?
>
> Richard
>
>
> gcc/
> 	* lra-constraints.c (process_address): Tighten arguments to
> 	base_reg_class.  Use simplify_gen_binary to generate PLUS rtxes.
>
>
It looks good.  Thanks, Richard.

Patch

Index: gcc/lra-constraints.c
===================================================================
--- gcc/lra-constraints.c	2012-10-25 09:55:17.000000000 +0100
+++ gcc/lra-constraints.c	2012-10-25 09:56:01.660283815 +0100
@@ -2721,15 +2721,14 @@  process_address (int nop, rtx *before, r
 	{
 	  /* index * scale + disp => new base + index * scale,
 	     case (1) above.  */
-	  enum reg_class cl = base_reg_class (mode, as, SCRATCH, SCRATCH);
+	  enum reg_class cl = base_reg_class (mode, as, PLUS,
+					      GET_CODE (*ad.index_loc));
 
 	  lra_assert (INDEX_REG_CLASS != NO_REGS);
 	  new_reg = lra_create_new_reg (Pmode, NULL_RTX, cl, "disp");
-	  lra_assert (GET_CODE (*addr_loc) == PLUS);
 	  lra_emit_move (new_reg, *ad.disp_loc);
-	  if (CONSTANT_P (XEXP (*addr_loc, 1)))
-	    XEXP (*addr_loc, 1) = XEXP (*addr_loc, 0);
-	  XEXP (*addr_loc, 0) = new_reg;
+	  *addr_loc = simplify_gen_binary (PLUS, GET_MODE (new_reg),
+					   new_reg, *ad.index_loc);
 	}
     }
   else if (ad.index_reg_loc == NULL)
@@ -2748,7 +2747,8 @@  process_address (int nop, rtx *before, r
       /* base + scale * index + disp => new base + scale * index,
 	 case (1) above.  */
       new_reg = base_plus_disp_to_reg (mode, as, &ad);
-      *addr_loc = gen_rtx_PLUS (Pmode, new_reg, *ad.index_loc);
+      *addr_loc = simplify_gen_binary (PLUS, GET_MODE (new_reg),
+				       new_reg, *ad.index_loc);
     }
   *before = get_insns ();
   end_sequence ();