[expmed] Avoid clobbering a yet-to-be-used base/index register.
diff mbox

Message ID 201505290206.t4T26rHk018433@greed.delorie.com
State New
Headers show

Commit Message

DJ Delorie May 29, 2015, 2:06 a.m. UTC
20040625-1 fails on targets with pointers bigger than WORD_SIZE (rl78,
msp430/-mlarge) because the base register is clobbered, partially
rebuilt with the new value, then used as a base for the second part of
the calculation.  Ok?

	* expmed.c (extract_bit_field_1): Avoid clobbering a
	yet-to-be-used base/index register.

Comments

Jeff Law May 30, 2015, 5:02 a.m. UTC | #1
On 05/28/2015 08:06 PM, DJ Delorie wrote:
> 20040625-1 fails on targets with pointers bigger than WORD_SIZE (rl78,
> msp430/-mlarge) because the base register is clobbered, partially
> rebuilt with the new value, then used as a base for the second part of
> the calculation.  Ok?
>
> 	* expmed.c (extract_bit_field_1): Avoid clobbering a
> 	yet-to-be-used base/index register.
OK.
jeff
DJ Delorie May 30, 2015, 6:06 a.m. UTC | #2
> > 	* expmed.c (extract_bit_field_1): Avoid clobbering a
> > 	yet-to-be-used base/index register.
> OK.
> jeff

Thanks! committed.

Patch
diff mbox

Index: expmed.c
===================================================================
--- expmed.c	(revision 223850)
+++ expmed.c	(working copy)
@@ -1613,12 +1613,17 @@  extract_bit_field_1 (rtx str_rtx, unsign
       unsigned int i;
       rtx_insn *last;
 
       if (target == 0 || !REG_P (target) || !valid_multiword_target_p (target))
 	target = gen_reg_rtx (mode);
 
+      /* In case we're about to clobber a base register or something 
+	 (see gcc.c-torture/execute/20040625-1.c).   */
+      if (reg_mentioned_p (target, str_rtx))
+	target = gen_reg_rtx (mode);
+
       /* Indicate for flow that the entire target reg is being set.  */
       emit_clobber (target);
 
       last = get_last_insn ();
       for (i = 0; i < nwords; i++)
 	{