public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96559] New: Wrong code with -march=z900 -mtune=z9-109
@ 2020-08-10 17:40 marxin at gcc dot gnu.org
2020-08-11 8:36 ` [Bug target/96559] " uweigand at gcc dot gnu.org
2020-08-11 9:46 ` marxin at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-08-10 17:40 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/96559] Wrong code with -march=z900 -mtune=z9-109
2020-08-10 17:40 [Bug target/96559] New: Wrong code with -march=z900 -mtune=z9-109 marxin at gcc dot gnu.org
@ 2020-08-11 8:36 ` uweigand at gcc dot gnu.org
2020-08-11 9:46 ` marxin at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: uweigand at gcc dot gnu.org @ 2020-08-11 8:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96559
--- Comment #1 from Ulrich Weigand <uweigand at gcc dot gnu.org> ---
> [...] as __clzdi2 points to the very same place as _Z11CeilingLog2v.
How do you get to that conclusion? Nothing in that assembler source sets
__clzdi2 to point to the same place as _Z11CeilingLog2v. The ".globl" simply
declares that there is a globally visible definition, from someplace outside
this file.
And in fact if I compile all the way to an object file and look at it using
"objdump --disassemble --reloc", I see:
0000000000000000 <_Z11CeilingLog2v>:
0: eb cf f0 60 00 24 stmg %r12,%r15,96(%r15)
6: a7 fb ff 60 aghi %r15,-160
a: c0 c0 00 00 00 00 larl %r12,a <_Z11CeilingLog2v+0xa>
c: R_390_PC32DBL .bss+0x2
10: e3 20 c0 00 00 04 lg %r2,0(%r12)
16: c0 e5 00 00 00 00 brasl %r14,16 <_Z11CeilingLog2v+0x16>
18: R_390_PC32DBL __clzdi2+0x2
1c: 42 20 c0 08 stc %r2,8(%r12)
20: e3 40 f1 10 00 04 lg %r4,272(%r15)
26: eb cf f1 00 00 04 lmg %r12,%r15,256(%r15)
2c: 07 f4 br %r4
And "nm" shows:
U __clzdi2
0000000000000008 B compute___trans_tmp_3
0000000000000000 B CountLeadingZeroes64_aValue
0000000000000000 T _Z11CeilingLog2v
So if the call to __clzdi2 ends up going to the wrong place, something must
have gone wrong at the link stage.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/96559] Wrong code with -march=z900 -mtune=z9-109
2020-08-10 17:40 [Bug target/96559] New: Wrong code with -march=z900 -mtune=z9-109 marxin at gcc dot gnu.org
2020-08-11 8:36 ` [Bug target/96559] " uweigand at gcc dot gnu.org
@ 2020-08-11 9:46 ` marxin at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-08-11 9:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96559
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
> U __clzdi2
> 0000000000000008 B compute___trans_tmp_3
> 0000000000000000 B CountLeadingZeroes64_aValue
> 0000000000000000 T _Z11CeilingLog2v
>
> So if the call to __clzdi2 ends up going to the wrong place, something must
> have gone wrong at the link stage.
Oh, you are right. The --reloc helps with the explanation.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-11 9:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-10 17:40 [Bug target/96559] New: Wrong code with -march=z900 -mtune=z9-109 marxin at gcc dot gnu.org
2020-08-11 8:36 ` [Bug target/96559] " uweigand at gcc dot gnu.org
2020-08-11 9:46 ` marxin at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).