https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96559
Bug ID: 96559
Summary: Wrong code with -march=z900 -mtune=z9-109
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: marxin at gcc dot gnu.org
CC: krebbel at gcc dot gnu.org
Target Milestone: ---
Host: x86_64-linux-gnu
Target: s390x-linux-gnu
For the following test-case (reduced from Firefox):
$ cat ff.ii
char compute___trans_tmp_3;
long CountLeadingZeroes64_aValue;
void CeilingLog2() {
compute___trans_tmp_3 = __builtin_clzll(CountLeadingZeroes64_aValue);
}
we end with:
$ ./xgcc -B. ff.ii -march=z900 -mtune=z9-109 -S -o/dev/stdout -O1
...
.globl __clzdi2
.align 8
.globl _Z11CeilingLog2v
.type _Z11CeilingLog2v, @function
_Z11CeilingLog2v:
.LFB0:
stmg %r12,%r15,96(%r15)
.LCFI0:
aghi %r15,-160
.LCFI1:
larl %r12,.LANCHOR0
lg %r2,0(%r12)
brasl %r14,__clzdi2
stc %r2,8(%r12)
lg %r4,272(%r15)
lmg %r12,%r15,256(%r15)
which is bogus as __clzdi2 points to the very same place as _Z11CeilingLog2v.
So
brasl %r14,__clzdi2 is an infinite loop.
The .globl for __clzdi2 is emitted in the following back-trace:
Breakpoint 5, default_globalize_label (stream=0x2712300, name=0x7ffff7700d50
"__clzdi2") at /home/marxin/Programming/gcc/gcc/varasm.c:7321
7321 fputs (GLOBAL_ASM_OP, stream);
Missing separate debuginfos, use: zypper install
libmpfr6-debuginfo-4.1.0-1.1.x86_64 libzstd1-debuginfo-1.4.5-2.2.x86_64
(gdb) bt
#0 default_globalize_label (stream=0x2712300, name=0x7ffff7700d50 "__clzdi2")
at /home/marxin/Programming/gcc/gcc/varasm.c:7321
#1 0x000000000125d536 in default_external_libcall (fun=0x7ffff7764648) at
/home/marxin/Programming/gcc/gcc/targhooks.c:107
#2 0x00000000016c5d15 in assemble_external_libcall (fun=0x7ffff7764648) at
/home/marxin/Programming/gcc/gcc/varasm.c:2506
#3 0x0000000000cf28f6 in emit_library_call_value_1 (retval=1,
orgfun=0x7ffff7764648, value=0x0, fn_type=<optimized out>, outmode=E_SImode,
nargs=1, args=<optimized out>) at /home/marxin/Programming/gcc/gcc/calls.c:5272
#4 0x00000000010dd18b in emit_library_call_value (fun=0x7ffff7764648,
value=0x0, fn_type=LCT_CONST, outmode=E_SImode, arg1=0x7ffff7764630,
arg1_mode=E_DImode) at /home/marxin/Programming/gcc/gcc/rtl.h:4245
#5 0x00000000010d06d2 in expand_unop (mode=E_DImode, unoptab=clz_optab,
op0=0x7ffff7764630, target=0x7ffff77644f8, unsignedp=1) at
/home/marxin/Programming/gcc/gcc/optabs.c:3059
#6 0x0000000000cd49d5 in expand_builtin_unop (target_mode=E_SImode,
exp=<call_expr 0x7ffff7758380>, target=0x7ffff77644f8, subtarget=<optimized
out>, op_optab=clz_optab) at /home/marxin/Programming/gcc/gcc/tree.h:3296
#7 0x0000000000cea061 in expand_builtin (exp=<call_expr 0x7ffff7758380>,
target=<optimized out>, subtarget=0x0, mode=E_SImode, ignore=0) at
/home/marxin/Programming/gcc/gcc/builtins.c:8236
#8 0x0000000000e38f5d in expand_expr_real_1 (exp=<call_expr 0x7ffff7758380>,
target=<optimized out>, tmode=E_SImode, modifier=EXPAND_NORMAL,
alt_rtl=0x7fffffffdb48, inner_reference_p=<optimized out>) at
/home/marxin/Programming/gcc/gcc/expr.c:11237
#9 0x0000000000e42281 in store_expr (exp=<call_expr 0x7ffff7758380>,
target=0x7ffff77644f8, call_param_p=<optimized out>, nontemporal=<optimized
out>, reverse=<optimized out>) at /home/marxin/Programming/gcc/gcc/expr.c:5852
#10 0x0000000000e444cf in expand_assignment (to=<ssa_name 0x7ffff75df438 3>,
from=<call_expr 0x7ffff7758380>, nontemporal=<optimized out>) at
/home/marxin/Programming/gcc/gcc/expr.c:5588
#11 0x0000000000d09e34 in expand_call_stmt (stmt=0x7ffff7fc4510) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:2701
#12 expand_gimple_stmt_1 (stmt=<gimple_call 0x7ffff7fc4510>) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:3682
#13 expand_gimple_stmt (stmt=<gimple_call 0x7ffff7fc4510>) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:3847
#14 0x0000000000d0f60b in expand_gimple_basic_block (bb=<optimized out>,
disable_tail_calls=<optimized out>) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:5888
#15 0x0000000000d110b7 in (anonymous namespace)::pass_expand::execute
(this=<optimized out>, fun=0x7ffff7759000) at
/home/marxin/Programming/gcc/gcc/cfgexpand.c:6572
#16 0x000000000112fd75 in execute_one_pass (pass=<opt_pass* 0x270b2b0
"expand"(245)>) at /home/marxin/Programming/gcc/gcc/passes.c:2509
#17 0x000000000113009a in execute_pass_list_1 (pass=<opt_pass* 0x270b2b0
"expand"(245)>) at /home/marxin/Programming/gcc/gcc/passes.c:2597
#18 0x0000000001130123 in execute_pass_list (fn=0x7ffff7759000, pass=<opt_pass*
0x2707570 "fixup_cfg"(96)>) at /home/marxin/Programming/gcc/gcc/passes.c:2608
#19 0x0000000000d44cec in cgraph_node::expand (this=<cgraph_node * const
0x7ffff775d000 "CeilingLog2"/2>) at
/home/marxin/Programming/gcc/gcc/context.h:48
#20 0x0000000000d462ff in expand_all_functions () at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:2472
#21 symbol_table::compile (this=0x7ffff75d9000) at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:2835
#22 0x0000000000d48713 in symbol_table::compile (this=0x7ffff75d9000) at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:3013
#23 symbol_table::finalize_compilation_unit (this=0x7ffff75d9000) at
/home/marxin/Programming/gcc/gcc/cgraphunit.c:3013
#24 0x0000000001265fae in compile_file () at
/home/marxin/Programming/gcc/gcc/toplev.c:482
#25 0x0000000001269243 in do_compile () at
/home/marxin/Programming/gcc/gcc/toplev.c:2324
#26 0x0000000001269539 in toplev::main (this=0x7fffffffe0de, argc=17,
argv=0x7fffffffe1e8) at /home/marxin/Programming/gcc/gcc/toplev.c:2463
#27 0x0000000001ed6c82 in main (argc=17, argv=0x7fffffffe1e8) at
/home/marxin/Programming/gcc/gcc/main.c:39