SUBREGs in move2add_note_store (Was: Re: RFA: fix rtl-optimization/56833)

Eric Botcazou ebotcazou@adacore.com
Fri May 24 07:57:00 GMT 2013


> I've found it is good to have also one mode to invalidate a register for
> all uses; it seems natural to use VOIDmode for that, and then we can use
> BLKmode for all but the first hard register of a multi-hard-reg register.

OK, that sounds sensible.

> I have attached the patch that makes the reload_cse_move2add sub-pass work
> the way it think it should be; it'll take some time to test this properly,
> though.

Thanks for your efforts.  Here's a preliminary review:

+/* Record that REG is being set to a value with the mode of REG.  */
+
+static void
+move2add_record_mode (rtx reg)
[...]
+  for (i = nregs; --i > 0; )
+    reg_mode[regno + i] = BLKmode;

+/* Check if REGNO contains a valid value in MODE.  */
+
+static bool
+move2add_valid_value_p (int regno, enum machine_mode mode)
[...]
+  for (i = hard_regno_nregs[regno][mode] - 1; i > 0; i--)
+    if (reg_mode[i] != BLKmode)
+      return false;

I think that a 'regno' is missing in the second hunk.  And can you use the 
same idiom for the loop in both cases (same initial value and iteration)?


@@ -1787,8 +1848,7 @@ move2add_use_add3_insn (rtx reg, rtx sym
   SET_SRC (pat) = plus_expr;
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-    if (reg_set_luid[i] > move2add_last_label_luid
-	&& reg_mode[i] == GET_MODE (reg)
+    if (move2add_valid_value_p (i, GET_MODE (reg))
 	&& reg_base_reg[i] < 0
 	&& reg_symbol_ref[i] != NULL_RTX
 	&& rtx_equal_p (sym, reg_symbol_ref[i]))

Note that you're weakening the mode equality test here.


@@ -2045,7 +2099,10 @@ reload_cse_move2add (rtx first)
 	      /* Reset the information about this register.  */
 	      int regno = REGNO (XEXP (note, 0));
 	      if (regno < FIRST_PSEUDO_REGISTER)
-		reg_set_luid[regno] = 0;
+		{
+		  move2add_record_mode (XEXP (note, 0));
+		  reg_set_luid[regno] = 0;
+		}
 	    }
 	}
       note_stores (PATTERN (insn), move2add_note_store, insn);
@@ -2082,7 +2139,7 @@ reload_cse_move2add (rtx first)
 	    {
 	      if (call_used_regs[i])
 		/* Reset the information about this register.  */
-		reg_set_luid[i] = 0;
+		reg_mode[i] = VOIDmode;
 	    }
 	}

@@ -2262,17 +2288,17 @@ move2add_note_store (rtx dst, const_rtx
[...]

+    invalidate:
+      /* Invalidate the contents of the register.  */
+      reg_set_luid[regno] = 0;
+      move2add_record_mode (dst);

The intent is the same, why don't we have the same code?


-- 
Eric Botcazou



More information about the Gcc-patches mailing list