On SH, gcc.dg/tree-prof/bb-reorg.c test fails with assembler
messages like:

/tmp/cc3RtxMk.s: 115: Error: displacement to defined symbol .L27 overflows
12-bit field

It happens with a branch from .text to .text.unlikely section
where the label .L27 is placed on.
I've found that bb-reorder makes crossing unconditional branches
into indirect jumps when the architecture doesn't have unconditional
branches that can span all of memory.  This is the case for SH and
the rtls for the above branch in .bbpart rtl dump look like:

(insn 172 156 173 10 (set (reg:SI 211)
        (label_ref:SI 155)) -1 (insn_list:REG_LABEL_OPERAND 155 (nil)))

(jump_insn 173 172 159 10 (set (pc)
        (reg:SI 211)) -1 (expr_list:REG_CROSSING_JUMP (nil)
        (nil)))

which will be assembled to the correct jmup instruction across
sections on this target.
It seems that local-alloc.c:update_equiv_regs replaces this
indirect jump back into a usual jump.  The corresponding part
of .lreg dump is

(jump_insn:HI 173 156 159 13 (set (pc)
        (label_ref:SI 155)) 219 {jump_compact} (expr_list:REG_CROSSING_JUMP
(nil)
        (nil)))

which is assembled to a bad short branch instruction on SH.
I'm testing the patch below, though SH has a separate issue with
constant pools for bb-reorg.c test.

--- ORIG/trunk/gcc/local-alloc.c        2008-01-17 09:41:36.000000000 +0900
+++ TMP/trunk/gcc/local-alloc.c 2008-02-14 11:14:04.000000000 +0900
@@ -1107,7 +1107,8 @@ update_equiv_regs (void)

          /* Don't substitute into a non-local goto, this confuses CFG.  */
          if (JUMP_P (insn)
-             && find_reg_note (insn, REG_NON_LOCAL_GOTO, NULL_RTX))
+             && (find_reg_note (insn, REG_NON_LOCAL_GOTO, NULL_RTX)
+                 || find_reg_note (insn, REG_CROSSING_JUMP, NULL_RTX)))
            continue;

          for (link = REG_NOTES (insn); link; link = XEXP (link, 1))


-- 
           Summary: Wrong branch instruction with -freorder-blocks-and-
                    partition on SH
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kkojima at gcc dot gnu dot org
GCC target triplet: sh4-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35190

Reply via email to