SH: far conditional branch
kaz Kojima
kkojima@rr.iij4u.or.jp
Fri Jun 28 02:46:00 GMT 2002
The appended source foo.c causes an ICE
Internal compiler error in output_branch, at config/sh/sh.c:1053
with -O -m4 -ml option for the sh4-unknown-linux-gnu-gcc
(mainline).
It seems that the appended parts of .mach and .dbr dump files
show what is going in this case. After the machine dependant
reorg phase, there are no "far" conditional branches, but
the dbr optimization makes them: dbr optimization deforms
conditional_branch Lnear
branch Lfar0
Lnear: branch Lfar1
to
conditional_branch Lfar1
branch Lfar0
where Lfar? are out of the medium (+-4096) range relative to pc.
My guess is that this breaks the assumption of output_branch.
kaz
--
-- foo.c --
#define INST asm("nop")
#define INST4 INST; INST; INST; INST
#define INSTL4 INST4; INST4; INST4; INST4
#define INSTL6 INSTL4; INSTL4; INSTL4; INSTL4
#define INSTL8 INSTL6; INSTL6; INSTL6; INSTL6
#define INSTLA INSTL8; INSTL8; INSTL8; INSTL8
#define INSTLC INSTLA; INSTLA; INSTLA; INSTLA
void
foo (int x, int y)
{
if (x)
goto far1;
goto far0;
lab:
INSTLC;
far0:
INSTLC;
far1:
if (y)
goto lab;
return;
}
-- .mach --
(jump_insn 11 10 8267 (nil) (set (pc)
(if_then_else (ne (reg:SI 147 t)
(const_int 0 [0x0]))
(label_ref 8263)
(pc))) 141 {branch_true} (insn_list 10 (nil))
(expr_list:REG_DEAD (reg:SI 147 t)
(expr_list:REG_BR_PROB (const_int 5000 [0x1388])
(nil))))
(insn 8267 11 8264 (nil) (set (pc)
(unspec [
(const_int 8217 [0x2019])
] 4)) -1 (nil)
(nil))
(jump_insn 8264 8267 8265 (nil) (set (pc)
(label_ref 8217)) -1 (nil)
(nil))
(barrier 8265 8264 8263)
(code_label 8263 8265 8234 10 "" "" [1 uses])
(note 8234 8263 19 [bb 1] NOTE_INSN_BASIC_BLOCK)
(jump_insn 19 8234 20 (nil) (set (pc)
(label_ref 4119)) 155 {jump_compact} (nil)
(nil))
[snip]
(code_label 4119 4118 8236 4 ("far0") "" [1 uses])
[snip]
(code_label 8217 8216 8237 3 ("far1") "" [1 uses])
-- .dbr --
(insn 8269 10 8267 (nil) (sequence [
(jump_insn 11 10 8245 (nil) (set (pc)
(if_then_else (ne (reg:SI 147 t)
(const_int 0 [0x0]))
(label_ref 4119)
(pc))) 141 {branch_true} (insn_list 10 (nil))
(expr_list:REG_BR_PRED (const_int 5 [0x5])
(expr_list:REG_DEAD (reg:SI 147 t)
(expr_list:REG_BR_PROB (const_int 5000 [0x1388])
(nil)))))
(insn/f 8245 11 8267 (nil) (set (reg/f:SI 14 r14)
(reg/f:SI 15 r15)) 113 {movsi_ie} (insn_list 8244 (nil))
(nil))
]) -1 (nil)
(nil))
(insn 8267 8269 8271 (nil) (set (pc)
(unspec [
(const_int 8217 [0x2019])
] 4)) 143 {block_branch_redirect} (nil)
(nil))
(insn 8271 8267 8272 (nil) (sequence [
(jump_insn 8264 8267 8219 (nil) (set (pc)
(label_ref 8270)) 155 {jump_compact} (nil)
(expr_list:REG_BR_PRED (const_int 12 [0xc])
(nil)))
(insn/s 8219 8264 8272 (nil) (set (reg:SI 147 t)
(eq:SI (reg/v:SI 5 r5 [159])
(const_int 0 [0x0]))) 1 {cmpeqsi_t} (nil)
(nil))
]) -1 (nil)
(nil))
[snip]
(code_label 4119 4118 8236 4 ("far0") "" [1 uses])
[snip]
(note 8217 8216 8237 ("far1") NOTE_INSN_DELETED_LABEL 3)
(note 8237 8217 8219 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 8219 8237 8270 (nil) (set (reg:SI 147 t)
(eq:SI (reg/v:SI 5 r5 [159])
(const_int 0 [0x0]))) 1 {cmpeqsi_t} (nil)
(nil))
(code_label 8270 8219 8220 11 "" "" [1 uses])
More information about the Gcc-bugs
mailing list