public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [SH][committed] Fix PR 65979 / PR 66611
@ 2015-06-26  2:36 Oleg Endo
  2015-06-27  1:33 ` Oleg Endo
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Endo @ 2015-06-26  2:36 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

Hi,

This fixes the problem of emitting an insn from within a peephole pattern which can't be recognized due to mismatching operand constraints.  Tested by Kaz on sh4-linux.  Committed to trunk as r224987.  Backport to GCC 5 will follow.

Cheers,
Oleg

gcc/ChangeLog:
	PR target/65979
	PR target/66611
	* config/sh/sh.md (tstsi_t peephole2): Use insn_invalid_p to check if
	the replacement insn will work.



[-- Attachment #2: sh_pr65979_pr66611.patch --]
[-- Type: application/octet-stream, Size: 1664 bytes --]

Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md	(revision 224565)
+++ gcc/config/sh/sh.md	(working copy)
@@ -14727,8 +14727,19 @@
   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])));
+  // We don't know what the new set insn will be in detail.  Just make sure
+  // that it still can be recognized and the constraints are satisfied.
+  rtx_insn* i = emit_insn (gen_rtx_SET (operands[2], operands[3]));
+						     
+  recog_data_d prev_recog_data = recog_data;
+  bool i_invalid = insn_invalid_p (i, false); 
+  recog_data = prev_recog_data;
+  
+  if (i_invalid)
+    FAIL;
+    
+  sh_check_add_incdec_notes (i);
+
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })
@@ -14755,8 +14766,19 @@
        || REGNO (operands[2]) == REGNO (operands[5]))"
   [(const_int 0)]
 {
-  sh_check_add_incdec_notes (emit_insn (gen_rtx_SET (operands[2],
-						     operands[3])));
+  // We don't know what the new set insn will be in detail.  Just make sure
+  // that it still can be recognized and the constraints are satisfied.
+  rtx_insn* i = emit_insn (gen_rtx_SET (operands[2], operands[3]));
+
+  recog_data_d prev_recog_data = recog_data;
+  bool i_invalid = insn_invalid_p (i, false); 
+  recog_data = prev_recog_data;
+  
+  if (i_invalid)
+    FAIL;
+    
+  sh_check_add_incdec_notes (i);
+  
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [SH][committed] Fix PR 65979 / PR 66611
  2015-06-26  2:36 [SH][committed] Fix PR 65979 / PR 66611 Oleg Endo
@ 2015-06-27  1:33 ` Oleg Endo
  0 siblings, 0 replies; 2+ messages in thread
From: Oleg Endo @ 2015-06-27  1:33 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]


On 26 Jun 2015, at 08:54, Oleg Endo <oleg.endo@t-online.de> wrote:

> Hi,
> 
> This fixes the problem of emitting an insn from within a peephole pattern which can't be recognized due to mismatching operand constraints.  Tested by Kaz on sh4-linux.  Committed to trunk as r224987.  Backport to GCC 5 will follow.

I've committed the attached patch to the GCC 5 branch as r225094.

Cheers,
Oleg


[-- Attachment #2: sh_pr65979_pr66611_gcc5.patch --]
[-- Type: application/octet-stream, Size: 1700 bytes --]

Index: gcc/config/sh/sh.md
===================================================================
--- gcc/config/sh/sh.md	(revision 224988)
+++ gcc/config/sh/sh.md	(working copy)
@@ -14692,8 +14692,19 @@
   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])));
+  // We don't know what the new set insn will be in detail.  Just make sure
+  // that it still can be recognized and the constraints are satisfied.
+  rtx_insn* i = emit_insn (gen_rtx_SET (VOIDmode, operands[2], operands[3]));
+						     
+  recog_data_d prev_recog_data = recog_data;
+  bool i_invalid = insn_invalid_p (i, false); 
+  recog_data = prev_recog_data;
+  
+  if (i_invalid)
+    FAIL;
+    
+  sh_check_add_incdec_notes (i);
+
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })
@@ -14720,8 +14731,19 @@
        || REGNO (operands[2]) == REGNO (operands[5]))"
   [(const_int 0)]
 {
-  sh_check_add_incdec_notes (emit_insn (gen_rtx_SET (SImode, operands[2],
-						     operands[3])));
+  // We don't know what the new set insn will be in detail.  Just make sure
+  // that it still can be recognized and the constraints are satisfied.
+  rtx_insn* i = emit_insn (gen_rtx_SET (VOIDmode, operands[2], operands[3]));
+
+  recog_data_d prev_recog_data = recog_data;
+  bool i_invalid = insn_invalid_p (i, false); 
+  recog_data = prev_recog_data;
+  
+  if (i_invalid)
+    FAIL;
+    
+  sh_check_add_incdec_notes (i);
+  
   emit_insn (gen_tstsi_t (operands[2],
 			  gen_rtx_REG (SImode, (REGNO (operands[1])))));
 })

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-27  0:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-26  2:36 [SH][committed] Fix PR 65979 / PR 66611 Oleg Endo
2015-06-27  1:33 ` Oleg Endo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).