diff mbox

[committed,SH] Fix PR target/62261

Message ID 20140828.082704.375776914.kkojima@rr.iij4u.or.jp
State New
Headers show

Commit Message

Kaz Kojima Aug. 27, 2014, 11:27 p.m. UTC
I've applied the attached patch to fix PR target/62261
which is a sh64 specific 4.9/5 regression.
The patch handles negative shift counts at some shift
paterns for shmedia.  Tested sh64-elf and sh4-unknown-linux-gnu
with no new failures.  I'll backport it to 4.9 in a weak
or two.

Regards,
	kaz
--
2014-08-27  Kaz Kojima  <kkojima@gcc.gnu.org>

        PR target/62261
        * config/sh/sh.md (ashlsi3): Handle negative shift count for
	TARGET_SHMEDIA.
	(ashldi3, ashrsi3, ashrdi3, lshrsi3, lshrdi3): Likewise.
diff mbox

Patch

--- ORIG/trunk/gcc/config/sh/sh.md	2014-07-03 09:10:37.000000000 +0900
+++ trunk/gcc/config/sh/sh.md	2014-08-20 12:03:03.540859362 +0900
@@ -4579,6 +4579,12 @@  label:
 {
   if (TARGET_SHMEDIA)
     {
+       if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 0)
+	{
+	  operands[2] = GEN_INT (-INTVAL (operands[2]));
+	  emit_insn (gen_ashrsi3_media (operands[0], operands[1], operands[2]));
+	  DONE;
+	}
       emit_insn (gen_ashlsi3_media (operands[0], operands[1], operands[2]));
       DONE;
     }
@@ -4819,6 +4825,12 @@  label:
 {
   if (TARGET_SHMEDIA)
     {
+       if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 0)
+	{
+	  operands[2] = GEN_INT (-INTVAL (operands[2]));
+	  emit_insn (gen_ashrdi3_media (operands[0], operands[1], operands[2]));
+	  DONE;
+	}
       emit_insn (gen_ashldi3_media (operands[0], operands[1], operands[2]));
       DONE;
     }
@@ -4912,6 +4924,12 @@  label:
 {
   if (TARGET_SHMEDIA)
     {
+      if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 0)
+	{
+	  operands[2] = GEN_INT (-INTVAL (operands[2]));
+	  emit_insn (gen_ashlsi3_media (operands[0], operands[1], operands[2]));
+	  DONE;
+	}
       emit_insn (gen_ashrsi3_media (operands[0], operands[1], operands[2]));
       DONE;
     }
@@ -5011,6 +5029,12 @@  label:
 {
   if (TARGET_SHMEDIA)
     {
+      if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 0)
+	{
+	  operands[2] = GEN_INT (-INTVAL (operands[2]));
+	  emit_insn (gen_ashldi3_media (operands[0], operands[1], operands[2]));
+	  DONE;
+	}
       emit_insn (gen_ashrdi3_media (operands[0], operands[1], operands[2]));
       DONE;
     }
@@ -5085,6 +5109,12 @@  label:
 {
   if (TARGET_SHMEDIA)
     {
+      if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 0)
+	{
+	  operands[2] = GEN_INT (-INTVAL (operands[2]));
+	  emit_insn (gen_ashlsi3_media (operands[0], operands[1], operands[2]));
+	  DONE;
+	}
       emit_insn (gen_lshrsi3_media (operands[0], operands[1], operands[2]));
       DONE;
     }
@@ -5279,6 +5309,12 @@  label:
 {
   if (TARGET_SHMEDIA)
     {
+      if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 0)
+	{
+	  operands[2] = GEN_INT (-INTVAL (operands[2]));
+	  emit_insn (gen_ashldi3_media (operands[0], operands[1], operands[2]));
+	  DONE;
+	}
       emit_insn (gen_lshrdi3_media (operands[0], operands[1], operands[2]));
       DONE;
     }