diff mbox

[commit,SH] Fix PR target/65979

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

Commit Message

Kaz Kojima May 26, 2015, 10:42 p.m. UTC
Hi,

I've committed the attached patches to fix PR target/65979
which is a 5/6 regression in behalf of Oleg.  The problematic
peephole can clobber a register before its use.  See PR65979 for
details.  The first patch is for trunk and the second one is
a slightly different version against gcc-5-branch.  Tested on
sh4-unknown-linux-gnu.

Regards,
	kaz
--
2015-05-26  Oleg Endo  <olegendo@gcc.gnu.org>

	PR target/65979
	* config/sh/sh.md (tstsi_t peephole2): Use gen_rtx_SET and
	take into account the case that operands[1] and operands[2]
	are the same register.

[trunk]
diff mbox

Patch

diff --git a/config/sh/sh.md b/config/sh/sh.md
index 3b66992..3a95739 100644
--- a/config/sh/sh.md
+++ b/config/sh/sh.md
@@ -14721,7 +14721,11 @@  label:
        || REGNO (operands[2]) == REGNO (operands[5]))"
   [(const_int 0)]
 {
-  sh_check_add_incdec_notes (emit_move_insn (operands[2], operands[3]));
+  if (REGNO (operands[1]) == REGNO (operands[2]))
+      operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));
+
+  sh_check_add_incdec_notes (emit_insn (gen_rtx_SET (operands[2],
+						     operands[3])));
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })
@@ -14748,7 +14752,8 @@  label:
        || REGNO (operands[2]) == REGNO (operands[5]))"
   [(const_int 0)]
 {
-  sh_check_add_incdec_notes (emit_move_insn (operands[2], operands[3]));
+  sh_check_add_incdec_notes (emit_insn (gen_rtx_SET (operands[2],
+						     operands[3])));
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })

[gcc-5-branch]
diff --git a/config/sh/sh.md b/config/sh/sh.md
index 24ddc9e..9f5e2d2 100644
--- a/config/sh/sh.md
+++ b/config/sh/sh.md
@@ -14683,7 +14683,11 @@  label:
        || REGNO (operands[2]) == REGNO (operands[5]))"
   [(const_int 0)]
 {
-  sh_check_add_incdec_notes (emit_move_insn (operands[2], operands[3]));
+  if (REGNO (operands[1]) == REGNO (operands[2]))
+      operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]));
+
+  sh_check_add_incdec_notes (emit_insn (gen_rtx_SET (SImode, operands[2],
+						     operands[3])));
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })
@@ -14710,7 +14714,8 @@  label:
        || REGNO (operands[2]) == REGNO (operands[5]))"
   [(const_int 0)]
 {
-  sh_check_add_incdec_notes (emit_move_insn (operands[2], operands[3]));
+  sh_check_add_incdec_notes (emit_insn (gen_rtx_SET (SImode, operands[2],
+						     operands[3])));
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })