[Bug target/64761] [4.9/5 Regression] -freorder-blocks-and-partition causes some failures on SH

kkojima at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Jan 24 01:16:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64761

--- Comment #3 from Kazumoto Kojima <kkojima at gcc dot gnu.org> ---
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.



More information about the Gcc-bugs mailing list