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

            Bug ID: 64761
           Summary: [4.9/5 Regression] -freorder-blocks-and-partition
                    causes some failures on SH
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kkojima at gcc dot gnu.org
            Target: sh*-*-*

For SH, we have two failures on testsuite

FAIL: gcc.dg/tree-prof/cold_partition_label.c compilation,  -fprofile-use
-D_PROFILE_USE (internal compiler error)
FAIL: gcc.dg/tree-prof/va-arg-pack-1.c compilation,  -fprofile-use
-D_PROFILE_USE (internal compiler error)

with -freorder-blocks-and-partition.  Although both test cases
are added at 4.9, they don't fail with 4.8.4 compiler.  So
this is a 4.9/5 regression from 4.8.
In both cases, (set (pc) (label_ref ...)) can't be recognized
because CROSSING_JUMP_P (insn) is set.  I've added a new insn

(define_insn "*jump_compact_crossing"
  [(set (pc)
    (label_ref (match_operand 0 "" "")))]
  "TARGET_SH1
   && flag_reorder_blocks_and_partition
   && CROSSING_JUMP_P (insn)"
{
  /* The length is 16 if the delay slot is unfilled.  */
  return output_far_jump (insn, operands[0]);
}
  [(set_attr "type" "jump")
   (set_attr "length" "16")])

to sh.md.  I guess that it's enough ATM, though it isn't optimal.
Then we get another failures for both tests like:

  Error: displacement to defined symbol .L10 overflows 8-bit field

from assembler.
It looks almost wrong branches came from follow jump optimization.
Giving SH specific TARGET_CAN_FOLLOW_JUMP target macro as

static bool
sh_can_follow_jump (const rtx_insn *, const rtx_insn *)
{
  if (TARGET_SH1
      && flag_reorder_blocks_and_partition
      && simplejump_p (branch2)
      && CROSSING_JUMP_P (branch2))
    return false;

  return true;
}

could fix them.  Joern had already proposed
https://gcc.gnu.org/ml/gcc-patches/2013-04/msg01332.html
which replaces MD_REDIRECT_BRANCH with TARGET_CAN_FOLLOW_JUMP
and these changes could be merged.  I'll attach the patches
for it.

Reply via email to