diff mbox

[SH] Fix for PR 53886

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

Commit Message

Oleg Endo July 9, 2012, 9:59 p.m. UTC
This time with the right patch attached.  Sorry.

On Mon, 2012-07-09 at 21:09 +0200, Oleg Endo wrote:
> Hello,
> 
> The attached patch is a fix for PR 53886, as suggested in the PR.
> I've also replaced another unchecked usage of 'PATTERN (NEXT_INSN
> (PREV_INSN (insn)))' in 'find_barrier', just in case.
> 
> Tested on rev 189361 with
> make -k check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,
> -m4-single/-ml,-m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}"
> 
> and no new failures.
> 
> Cheers,
> Oleg
> 
> ChangeLog:
> 
> 	PR target/53886
> 	* config/sh/sh.c (sequence_insn_p): New function.
> 	(find_barrier, sh_insn_length_adjustment): Use it.

Comments

Kaz Kojima July 9, 2012, 10:31 p.m. UTC | #1
Oleg Endo <oleg.endo@t-online.de> wrote:
> This time with the right patch attached.  Sorry.
> 
> On Mon, 2012-07-09 at 21:09 +0200, Oleg Endo wrote:
>> Hello,
>> 
>> The attached patch is a fix for PR 53886, as suggested in the PR.
>> I've also replaced another unchecked usage of 'PATTERN (NEXT_INSN
>> (PREV_INSN (insn)))' in 'find_barrier', just in case.

OK for trunk.

Regards,
	kaz
diff mbox

Patch

Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c	(revision 189362)
+++ gcc/config/sh/sh.c	(working copy)
@@ -303,6 +303,7 @@ 
 static int max_mov_insn_displacement (enum machine_mode, bool);
 static int mov_insn_alignment_mask (enum machine_mode, bool);
 static HOST_WIDE_INT disp_addr_displacement (rtx);
+static bool sequence_insn_p (rtx);
 
 static void sh_init_sync_libfuncs (void) ATTRIBUTE_UNUSED;
 
@@ -4794,7 +4795,7 @@ 
 	 delay slot scheduler.  */
       if (JUMP_P (from) && !JUMP_TABLE_DATA_P (from) 
 	  && get_attr_type (from) == TYPE_CBRANCH
-	  && GET_CODE (PATTERN (NEXT_INSN (PREV_INSN (from)))) != SEQUENCE)
+	  && ! sequence_insn_p (from))
 	inc += 2;
 
       if (found_si)
@@ -9661,6 +9662,26 @@ 
 #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == ';')
 #endif
 
+static bool
+sequence_insn_p (rtx insn)
+{
+  rtx prev, next, pat;
+
+  prev = PREV_INSN (insn);
+  if (prev == NULL)
+    return false;
+
+  next = NEXT_INSN (prev);
+  if (next == NULL)
+    return false;
+
+  pat = PATTERN (next);
+  if (pat == NULL)
+    return false;
+
+  return GET_CODE (pat) == SEQUENCE;
+}
+
 int
 sh_insn_length_adjustment (rtx insn)
 {
@@ -9671,7 +9692,7 @@ 
 	&& GET_CODE (PATTERN (insn)) != CLOBBER)
        || CALL_P (insn)
        || (JUMP_P (insn) && !JUMP_TABLE_DATA_P (insn)))
-      && GET_CODE (PATTERN (NEXT_INSN (PREV_INSN (insn)))) != SEQUENCE
+      && ! sequence_insn_p (insn)
       && get_attr_needs_delay_slot (insn) == NEEDS_DELAY_SLOT_YES)
     return 2;
 
@@ -9680,7 +9701,7 @@ 
   if (sh_cpu_attr == CPU_SH2E
       && JUMP_P (insn) && !JUMP_TABLE_DATA_P (insn)
       && get_attr_type (insn) == TYPE_CBRANCH
-      && GET_CODE (PATTERN (NEXT_INSN (PREV_INSN (insn)))) != SEQUENCE)
+      && ! sequence_insn_p (insn))
     return 2;
 
   /* sh-dsp parallel processing insn take four bytes instead of two.  */