This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Commit: MSP430: Optimize 1 bit shifts


Hi Guys,

  I am applying this patch, developed by DJ, to improve the code
  generated for the MSP430 when performing a shift by a single bit.
  Normally a helper function is used to perform N-bit shifts, but
  for one bit we can save time, and not use up any more space, by
  performing the shift inline.

Cheers
  Nick

gcc/ChangeLog
2016-04-25  DJ Delorie  <dj@redhat.com>

	* config/msp430/msp430.md (ashlhi3): Optimize one bit shifts.
	(ashrhi3): Likewise.
	(lshrhi3): Likewise.

Index: gcc/config/msp430/msp430.md
===================================================================
--- gcc/config/msp430/msp430.md	(revision 235409)
+++ gcc/config/msp430/msp430.md	(working copy)
@@ -756,6 +756,9 @@
         && REG_P (operands[1])
         && CONST_INT_P (operands[2]))
       emit_insn (gen_430x_shift_left (operands[0], operands[1], operands[2]));
+    else if (CONST_INT_P (operands[2])
+	     && INTVAL (operands[2]) == 1)
+      emit_insn (gen_slli_1 (operands[0], operands[1]));
     else		 
       msp430_expand_helper (operands, \"__mspabi_slli\", true);
     DONE;
@@ -825,6 +828,9 @@
         && REG_P (operands[1])
         && CONST_INT_P (operands[2]))
       emit_insn (gen_430x_arithmetic_shift_right (operands[0], operands[1], operands[2]));
+    else if (CONST_INT_P (operands[2])
+	     && INTVAL (operands[2]) == 1)
+      emit_insn (gen_srai_1 (operands[0], operands[1]));
     else		 
        msp430_expand_helper (operands, \"__mspabi_srai\", true);
    DONE;
@@ -910,6 +916,9 @@
         && REG_P (operands[1])
         && CONST_INT_P (operands[2]))
       emit_insn (gen_430x_logical_shift_right (operands[0], operands[1], operands[2]));
+    else if (CONST_INT_P (operands[2])
+	     && INTVAL (operands[2]) == 1)
+      emit_insn (gen_srli_1 (operands[0], operands[1]));
     else		 
       msp430_expand_helper (operands, \"__mspabi_srli\", true);
     DONE;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]