diff mbox

[5/9] Create sensible dummy registers

Message ID 871tidu4oo.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford May 18, 2015, 6:21 p.m. UTC
Some pieces of code create a temporary REG or MEM and only fill it
in later when they're testing the cost of a particular rtx.  This patch
makes sure that even the dummy REG or MEM is valid, rather than force
the gen_* code to handle garbage values.


gcc/
	* caller-save.c (init_caller_save): Use word_mode and
	FIRST_PSEUDO_REGISTER when creating temporary rtxes.
	* expr.c (init_expr_target): Likewise.
	* ira.c (setup_prohibited_mode_move_regs): Likewise.
	* postreload.c (reload_cse_regs_1): Likewise.

Comments

Jeff Law May 18, 2015, 8:41 p.m. UTC | #1
On 05/18/2015 12:21 PM, Richard Sandiford wrote:
> Some pieces of code create a temporary REG or MEM and only fill it
> in later when they're testing the cost of a particular rtx.  This patch
> makes sure that even the dummy REG or MEM is valid, rather than force
> the gen_* code to handle garbage values.
>
>
> gcc/
> 	* caller-save.c (init_caller_save): Use word_mode and
> 	FIRST_PSEUDO_REGISTER when creating temporary rtxes.
> 	* expr.c (init_expr_target): Likewise.
> 	* ira.c (setup_prohibited_mode_move_regs): Likewise.
> 	* postreload.c (reload_cse_regs_1): Likewise.
OK.
jeff
Eric Botcazou May 19, 2015, 8:54 a.m. UTC | #2
> Some pieces of code create a temporary REG or MEM and only fill it
> in later when they're testing the cost of a particular rtx.  This patch
> makes sure that even the dummy REG or MEM is valid, rather than force
> the gen_* code to handle garbage values.
> 
> 
> gcc/
> 	* caller-save.c (init_caller_save): Use word_mode and
> 	FIRST_PSEUDO_REGISTER when creating temporary rtxes.
> 	* expr.c (init_expr_target): Likewise.
> 	* ira.c (setup_prohibited_mode_move_regs): Likewise.
> 	* postreload.c (reload_cse_regs_1): Likewise.

Isn't LAST_VIRTUAL_REGISTER + 1 the canonical regno to be used in this case?
diff mbox

Patch

Index: gcc/caller-save.c
===================================================================
--- gcc/caller-save.c	2015-05-16 15:50:58.063567104 +0100
+++ gcc/caller-save.c	2015-05-16 15:50:58.055567198 +0100
@@ -287,8 +287,8 @@  init_caller_save (void)
      To avoid lots of unnecessary RTL allocation, we construct all the RTL
      once, then modify the memory and register operands in-place.  */
 
-  test_reg = gen_rtx_REG (VOIDmode, 0);
-  test_mem = gen_rtx_MEM (VOIDmode, address);
+  test_reg = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER);
+  test_mem = gen_rtx_MEM (word_mode, address);
   savepat = gen_rtx_SET (test_mem, test_reg);
   restpat = gen_rtx_SET (test_reg, test_mem);
 
Index: gcc/expr.c
===================================================================
--- gcc/expr.c	2015-05-16 15:50:58.063567104 +0100
+++ gcc/expr.c	2015-05-16 15:50:58.059567152 +0100
@@ -202,12 +202,12 @@  init_expr_target (void)
   /* Try indexing by frame ptr and try by stack ptr.
      It is known that on the Convex the stack ptr isn't a valid index.
      With luck, one or the other is valid on any machine.  */
-  mem = gen_rtx_MEM (VOIDmode, stack_pointer_rtx);
-  mem1 = gen_rtx_MEM (VOIDmode, frame_pointer_rtx);
+  mem = gen_rtx_MEM (word_mode, stack_pointer_rtx);
+  mem1 = gen_rtx_MEM (word_mode, frame_pointer_rtx);
 
   /* A scratch register we can modify in-place below to avoid
      useless RTL allocations.  */
-  reg = gen_rtx_REG (VOIDmode, -1);
+  reg = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER);
 
   insn = rtx_alloc (INSN);
   pat = gen_rtx_SET (NULL_RTX, NULL_RTX);
Index: gcc/ira.c
===================================================================
--- gcc/ira.c	2015-05-16 15:50:58.063567104 +0100
+++ gcc/ira.c	2015-05-16 15:50:58.055567198 +0100
@@ -1767,8 +1767,8 @@  setup_prohibited_mode_move_regs (void)
   if (ira_prohibited_mode_move_regs_initialized_p)
     return;
   ira_prohibited_mode_move_regs_initialized_p = true;
-  test_reg1 = gen_rtx_REG (VOIDmode, 0);
-  test_reg2 = gen_rtx_REG (VOIDmode, 0);
+  test_reg1 = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER);
+  test_reg2 = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER);
   move_pat = gen_rtx_SET (test_reg1, test_reg2);
   move_insn = gen_rtx_INSN (VOIDmode, 0, 0, 0, move_pat, 0, -1, 0);
   for (i = 0; i < NUM_MACHINE_MODES; i++)
Index: gcc/postreload.c
===================================================================
--- gcc/postreload.c	2015-05-16 15:50:58.063567104 +0100
+++ gcc/postreload.c	2015-05-16 15:50:58.055567198 +0100
@@ -234,7 +234,7 @@  reload_cse_regs_1 (void)
   bool cfg_changed = false;
   basic_block bb;
   rtx_insn *insn;
-  rtx testreg = gen_rtx_REG (VOIDmode, -1);
+  rtx testreg = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER);
 
   cselib_init (CSELIB_RECORD_MEMORY);
   init_alias_analysis ();