From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18156 invoked by alias); 24 Jan 2015 01:16:27 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 17976 invoked by uid 48); 24 Jan 2015 01:15:58 -0000 From: "kkojima at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64761] [4.9/5 Regression] -freorder-blocks-and-partition causes some failures on SH Date: Sat, 24 Jan 2015 01:16:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: kkojima at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg02658.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64761 --- Comment #3 from Kazumoto Kojima --- Even after these changes, Error: displacement to defined symbol .L59 overflows 12-bit field remains for va-arg-pack-1.c and a new failure Error: displacement to defined symbol .L31 overflows 8-bit field pops up for gcc.dg/tree-prof/20041218-1.c. These wrong branches crossing between partitions were created by dbr_schedule. For va-arg-pack-1.c, it seems that relax_delay_slots in dbr_schedule pass does a variant of follow jump optimization without checking targetm.can_follow_jump. The patch below fixes it. diff --git a/reorg.c b/reorg.c index 326fa53..2ac6dcf 100644 --- a/reorg.c +++ b/reorg.c @@ -3262,12 +3263,13 @@ relax_delay_slots (rtx_insn *first) /* See if this jump conditionally branches around an unconditional jump. If so, invert this jump and point it to the target of the - second jump. */ + second jump. Check if it's possible on the target. */ if (next && simplejump_or_return_p (next) && any_condjump_p (insn) && target_label && next_active_insn (target_label) == next_active_insn (next) - && no_labels_between_p (insn, next)) + && no_labels_between_p (insn, next) + && targetm.can_follow_jump (insn, next)) { rtx label = JUMP_LABEL (next); For 20041218-1.c, relax_delay_slots deletes the jump_insn 74 bellow as a trivial jump to the next insn ignoring that this jump is a crossing jump between hot/cold partitions. Notice that there is a NOTE_INSN_SWITCH_TEXT_SECTIONS note between the jump and its target label. ... (jump_insn/j 74 58 59 (set (pc) (label_ref:SI 29)) 312 {*jump_compact_crossing} (nil) -> 29) (barrier 59 74 105) (note 105 59 29 NOTE_INSN_SWITCH_TEXT_SECTIONS) (code_label 29 105 30 31 "" [5 uses]) (note 30 29 31 [bb 13] NOTE_INSN_BASIC_BLOCK) (insn 31 30 32 (set (reg/f:SI 5 r5 [178]) (mem/u/c:SI (label_ref 108) [0 S4 A32])) ... It seems that we should take account of crossing jumps here. The patch diff --git a/reorg.c b/reorg.c index 326fa53..2ac6dcf 100644 --- a/reorg.c +++ b/reorg.c @@ -3247,6 +3247,7 @@ relax_delay_slots (rtx_insn *first) target_label = find_end_label (target_label); if (target_label && next_active_insn (target_label) == next + && ! (CROSSING_JUMP_P (insn) || crossing) && ! condjump_in_parallel_p (insn)) { delete_jump (insn); fixes the issue.