diff mbox

[SH] PR 54089 - Convert dyn left shifts to constant shifts

Message ID 1343602726.2304.16.camel@yam-132-YW-E178-FTW
State New
Headers show

Commit Message

Oleg Endo July 29, 2012, 10:58 p.m. UTC
Hello,

In cases where dynamic shifts are available, the ashlsi3_d pattern is
picked first and never converted back to a short sequence of constant
shifts.  Preferring short constant shift sequences over dynamic shifts
can potentially reduce the need for an extra register to hold the shift
count.  CSiBE shows some code size increases and decreases with this
patch.  The increases seem to be due to some unlucky register
allocations.  Overall there is a small decrease (-312 bytes on the whole
set for '-O2 -m4-single -ml -mpretend-cmove).

Tested on rev 189916 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
-m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}"

and no new failures.

OK?

Cheers,
Oleg

ChangeLog:
        PR target/54089
        * config/sh/sh.md (ashlsi3_d): Invoke gen_shifty_op directly
        instead of trying to emit ashlsi3_n.

Comments

Kaz Kojima July 30, 2012, 3:14 a.m. UTC | #1
Oleg Endo <oleg.endo@t-online.de> wrote:
> In cases where dynamic shifts are available, the ashlsi3_d pattern is
> picked first and never converted back to a short sequence of constant
> shifts.  Preferring short constant shift sequences over dynamic shifts
> can potentially reduce the need for an extra register to hold the shift
> count.  CSiBE shows some code size increases and decreases with this
> patch.  The increases seem to be due to some unlucky register
> allocations.  Overall there is a small decrease (-312 bytes on the whole
> set for '-O2 -m4-single -ml -mpretend-cmove).
> 
> Tested on rev 189916 with
> make -k check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
> -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}"
> 
> and no new failures.
> 
> OK?

OK.

Regards,
	kaz
diff mbox

Patch

Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md	(revision 189916)
+++ gcc/config/sh/sh.md	(working copy)
@@ -3533,7 +3533,12 @@ 
     }
   else if (!satisfies_constraint_P27 (operands[2]))
     {
-      emit_insn (gen_ashlsi3_n (operands[0], operands[1], operands[2]));
+      /* 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.  */
+      emit_move_insn (operands[0], operands[1]);
+      gen_shifty_op (ASHIFT, operands);
       DONE;
     }