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

Submitted by Oleg Endo on July 29, 2012, 10:52 p.m.

Details

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

Commit Message

Oleg Endo July 29, 2012, 10:52 p.m.
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).

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.

Patch hide | download patch | download mbox

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;
     }