https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124383
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
Since flag_reorder_blocks_and_partition is enabled for x86:
common/config/i386/i386-common.cc: { OPT_LEVELS_2_PLUS,
OPT_freorder_blocks_and_partition, NULL, 1 },
try_optimize_cfg won't fold the jump:
/* Do not turn non-crossing jump to crossing. Depending on target
it may require different instruction pattern. */
if ((e->flags & EDGE_CROSSING)
|| BB_PARTITION (first) == BB_PARTITION (new_target))
{
target = new_target;
threaded |= new_target_threaded;
}
where first is hot:
(code_label 34 30 35 6 1 (nil) [2 uses])
(note 35 34 42 6 [bb 6] NOTE_INSN_BASIC_BLOCK)
(note 42 35 43 6 NOTE_INSN_EPILOGUE_BEG)
(jump_insn 43 42 0 6 (simple_return)
"/export/home/hjl/bugs/gcc/pr47253/cold-3.c":20:1 1521 {simple_return_internal}
(nil)
-> simple_return)
and new_target, sibcall, is cold:
(code_label 24 22 25 9 4 (nil) [1 uses])
(note 25 24 26 9 [bb 9] NOTE_INSN_BASIC_BLOCK)
(call_insn/j 26 25 28 9 (call (mem:QI (symbol_ref:DI ("bar2") [flags 0x41]
<function_decl 0x7fdb079cd400 bar2>) [0 bar2 S1 A8])
(const_int 0 [0])) "/export/home/hjl/bugs/gcc/pr47253/cold-3.c":14:7
1501 {*sibcall}
(expr_list:REG_CALL_DECL (symbol_ref:DI ("bar2") [flags 0x41]
<function_decl 0x7fdb079cd400 bar2>)
(nil))
(nil))