Patchwork [SH] PR 54089

login
register
mail settings
Submitter Oleg Endo
Date Aug. 16, 2012, 6 p.m.
Message ID <1345140050.3584.11.camel@yam-132-YW-E178-FTW>
Download mbox | patch
Permalink /patch/178057/
State New
Headers show

Comments

Oleg Endo - Aug. 16, 2012, 6 p.m.
Hello,

This fixes the case where a dynamic shift would expand into a P27 shift
sequence that clobbers T_REG, which would result in wrong code.
Tested on rev 190396 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

and no new failures.
OK?

Cheers,
Oleg

ChangeLog:

	PR target/54089
	* config/gcc/sh/sh.md (ashlsi3_d): Do not split if it would 
	result in a T_REG clobber.  Correct comment.
	(ashlsi3_n): Correct comment.
Kaz Kojima - Aug. 16, 2012, 10:10 p.m.
Oleg Endo <oleg.endo@t-online.de> wrote:
> This fixes the case where a dynamic shift would expand into a P27 shift
> sequence that clobbers T_REG, which would result in wrong code.
> Tested on rev 190396 with
> make -k check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
> 
> and no new failures.
> OK?

OK.

Regards,
	kaz

Patch

Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md	(revision 190396)
+++ gcc/config/sh/sh.md	(working copy)
@@ -3746,7 +3746,8 @@ 
 		   (match_operand:SI 2 "shift_count_operand" "r")))]
   "TARGET_DYNSHIFT"
   "shld	%2,%0"
-  "&& (CONST_INT_P (operands[2]) && ! sh_dynamicalize_shift_p (operands[2]))"
+  "&& CONST_INT_P (operands[2]) && ! sh_dynamicalize_shift_p (operands[2])
+   && ! sh_ashlsi_clobbers_t_reg_p (operands[2])"
   [(const_int 0)]
 {
   if (satisfies_constraint_P27 (operands[2]))
@@ -3759,7 +3760,9 @@ 
       /* This must happen before reload, otherwise the constant will be moved
 	 into a register due to the "r" constraint, after which this split
 	 cannot be done anymore.
-	 Unfortunately the move insn will not always be eliminated.  */
+	 Unfortunately the move insn will not always be eliminated.
+	 Also, here we must not create a shift sequence that clobbers the
+	 T_REG.  */
       emit_move_insn (operands[0], operands[1]);
       gen_shifty_op (ASHIFT, operands);
       DONE;
@@ -3782,8 +3785,7 @@ 
   if (sh_dynamicalize_shift_p (operands[2]) && can_create_pseudo_p ())
     {
       /* If this pattern was picked and dynamic shifts are supported, switch
-	 to dynamic shift pattern before reload.  However, we must not
-	 create a shift sequence that clobbers the T_REG.  */
+	 to dynamic shift pattern before reload.  */
       operands[2] = force_reg (SImode, operands[2]);
       emit_insn (gen_ashlsi3_d (operands[0], operands[1], operands[2]));
     }