public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
@ 2022-04-25 19:42 zsojka at seznam dot cz
  2022-04-25 19:45 ` [Bug tree-optimization/105384] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2022-04-25 19:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

            Bug ID: 105384
           Summary: compilation never (?) finishes with __builtin_yn{,f,l}
                    at -O and above
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

Created attachment 52874
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52874&action=edit
reduced testcase

I don't know if this should be reported against gcc or libmpfr.

Compiler output:
$ x86_64-pc-linux-gnu-gcc -O testcase.c -wrapper gdb,-q,--args
Reading symbols from
/repo/gcc-trunk/binary-trunk-r12-8242-20220425114659-gf0e170f72f8-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.0.1/cc1...
r
(gdb) r
Starting program:
/repo/gcc-trunk/binary-trunk-r12-8242-20220425114659-gf0e170f72f8-checking-yes-rtl-df-extra-nobootstrap-amd64/libexec/gcc/x86_64-pc-linux-gnu/12.0.1/cc1
-quiet -iprefix
/repo/gcc-trunk/binary-trunk-r12-8242-20220425114659-gf0e170f72f8-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.1/
testcase.c -quiet -dumpdir a- -dumpbase testcase.c -dumpbase-ext .c
-mtune=generic -march=x86-64 -O -o /tmp/ccIIYJf7.s
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
^C
Program received signal SIGINT, Interrupt.
0x00007ffff7c8ee22 in __gmpn_mul_1 () from /usr/lib64/libgmp.so.10
(gdb) bt
#0  0x00007ffff7c8ee22 in __gmpn_mul_1 () from /usr/lib64/libgmp.so.10
#1  0x00000000000155b7 in ?? ()
#2  0x00007ffff7c8503a in __gmpz_mul_ui () from /usr/lib64/libgmp.so.10
#3  0x00007ffff7d3964f in mpfr_yn () from /usr/lib64/libmpfr.so.6
#4  0x000000000100fe4a in do_mpfr_arg2 (result=result@entry=0x7fffffffc360,
func=0x643db0 <mpfr_yn@plt>, arg0=..., arg1=arg1@entry=0x7ffff7836260, 
    format=format@entry=0x26bb4c0 <ieee_double_format>) at
/repo/gcc-trunk/gcc/fold-const-call.cc:232
#5  0x0000000001012573 in do_mpfr_arg2 (format=0x26bb4c0 <ieee_double_format>,
arg1=0x7ffff7836260, arg0=..., func=<optimized out>, result=0x7fffffffc360)
    at /repo/gcc-trunk/gcc/fold-const-call.cc:222
#6  fold_const_call_sss (format=0x26bb4c0 <ieee_double_format>,
arg1=0x7ffff7836260, arg0=..., fn=CFN_BUILT_IN_YN, result=0x7fffffffc360) at
/repo/gcc-trunk/gcc/fold-const-call.cc:1466
#7  fold_const_call_1 (fn=CFN_BUILT_IN_YN, type=0x7ffff770c348,
arg0=0x7ffff7708438, arg1=<optimized out>) at
/repo/gcc-trunk/gcc/fold-const-call.cc:1562
#8  0x0000000000e4ab9b in fold_builtin_2 (arg1=0x7ffff7833450,
arg0=0x7ffff7708438, fndecl=0x7ffff778c800, expr=0x0, loc=254475) at
/repo/gcc-trunk/gcc/builtins.cc:9376
#9  fold_builtin_n (loc=254475, expr=0x0, fndecl=0x7ffff778c800,
args=<optimized out>, nargs=<optimized out>) at
/repo/gcc-trunk/gcc/builtins.cc:9540
#10 0x0000000000fdcf3b in fold_build_call_array_loc (loc=loc@entry=254475,
type=0x7ffff770c348, fn=fn@entry=0x7ffff7836220, nargs=nargs@entry=2,
argarray=argarray@entry=0x7ffff7821d50)
    at /repo/gcc-trunk/gcc/fold-const.cc:13965
#11 0x0000000000d52b40 in build_function_call_vec (loc=<optimized out>,
arg_loc=..., function=<optimized out>, params=<optimized out>,
origtypes=<optimized out>, 
    orig_fundecl=<optimized out>) at /repo/gcc-trunk/gcc/tree.h:3572
#12 0x0000000000d74094 in c_parser_postfix_expression_after_primary
(parser=0x7ffff76f7b40, expr_loc=254475, expr=...) at
/repo/gcc-trunk/gcc/c/c-parser.cc:10560
#13 0x0000000000d6b3e1 in c_parser_postfix_expression (parser=<optimized out>)
at /repo/gcc-trunk/gcc/c/c-parser.cc:10234
#14 0x0000000000d6f8eb in c_parser_unary_expression (parser=0x7ffff76f7b40) at
/repo/gcc-trunk/gcc/c/c-parser.cc:8261
#15 0x0000000000d71082 in c_parser_cast_expression (parser=0x7ffff76f7b40,
after=0x0) at /repo/gcc-trunk/gcc/c/c-parser.cc:8103
#16 0x0000000000d712ef in c_parser_binary_expression (parser=0x7ffff76f7b40,
after=0x0, omp_atomic_lhs=0x0) at /repo/gcc-trunk/gcc/c/c-parser.cc:7906
#17 0x0000000000d7277c in c_parser_conditional_expression
(parser=0x7ffff76f7b40, after=<optimized out>, omp_atomic_lhs=0x0) at
/repo/gcc-trunk/gcc/c/c-parser.cc:7606
#18 0x0000000000d72fa1 in c_parser_expr_no_commas (parser=0x7ffff76f7b40,
after=<optimized out>, omp_atomic_lhs=<optimized out>) at
/repo/gcc-trunk/gcc/c/c-parser.cc:7521
#19 0x0000000000d73212 in c_parser_expression (parser=0x7ffff76f7b40) at
/repo/gcc-trunk/gcc/c/c-parser.cc:10697
#20 0x0000000000d73979 in c_parser_expression_conv (parser=0x7ffff76f7b40) at
/repo/gcc-trunk/gcc/c/c-parser.cc:10736
#21 0x0000000000d68958 in c_parser_statement_after_labels
(parser=0x7ffff76f7b40, if_p=0x0, chain=0x0) at
/repo/gcc-trunk/gcc/c/c-parser.cc:6263
#22 0x0000000000d6af3b in c_parser_compound_statement_nostart
(parser=0x7ffff76f7b40) at /repo/gcc-trunk/gcc/c/c-parser.cc:5800
#23 0x0000000000d8ae86 in c_parser_compound_statement
(parser=parser@entry=0x7ffff76f7b40, endlocp=endlocp@entry=0x7fffffffd280) at
/repo/gcc-trunk/gcc/c/c-parser.cc:5609
#24 0x0000000000d8c909 in c_parser_declaration_or_fndef (parser=0x7ffff76f7b40,
fndef_ok=<optimized out>, static_assert_ok=<optimized out>, empty_ok=<optimized
out>, 
    nested=<optimized out>, start_attr_ok=<optimized out>,
objc_foreach_object_declaration=<optimized out>,
omp_declare_simd_clauses=<optimized out>, have_attrs=<optimized out>, 
    attrs=<optimized out>, oacc_routine_data=<optimized out>,
fallthru_attr_p=<optimized out>) at /repo/gcc-trunk/gcc/c/c-parser.cc:2544
#25 0x0000000000d94a54 in c_parser_external_declaration (parser=0x7ffff76f7b40)
at /repo/gcc-trunk/gcc/c/c-parser.cc:1779
#26 0x0000000000d9549c in c_parser_translation_unit (parser=<optimized out>) at
/repo/gcc-trunk/gcc/c/c-parser.cc:1652
#27 c_parse_file () at /repo/gcc-trunk/gcc/c/c-parser.cc:23357
#28 0x0000000000df6c8e in c_common_parse_file () at
/repo/gcc-trunk/gcc/c-family/c-opts.cc:1240
#29 0x00000000013a3ede in compile_file () at /repo/gcc-trunk/gcc/toplev.cc:452
#30 0x0000000000d0528e in do_compile (no_backend=false) at
/repo/gcc-trunk/gcc/toplev.cc:2168
#31 toplev::main (this=this@entry=0x7fffffffd57e, argc=<optimized out>,
argc@entry=17, argv=<optimized out>, argv@entry=0x7fffffffd6c8) at
/repo/gcc-trunk/gcc/toplev.cc:2320
#32 0x0000000000d071cf in main (argc=17, argv=0x7fffffffd6c8) at
/repo/gcc-trunk/gcc/main.cc:39


The execution doesn't seem to ever finish.

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r12-8242-20220425114659-gf0e170f72f8-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r12-8242-20220425114659-gf0e170f72f8-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220425 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
@ 2022-04-25 19:45 ` pinskia at gcc dot gnu.org
  2022-04-25 19:46 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-25 19:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
What version of gmp, mpfr are you using?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
  2022-04-25 19:45 ` [Bug tree-optimization/105384] " pinskia at gcc dot gnu.org
@ 2022-04-25 19:46 ` pinskia at gcc dot gnu.org
  2022-04-25 19:52 ` zsojka at seznam dot cz
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-25 19:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Can you try the one that is downloaded via contrib/download_pre*.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
  2022-04-25 19:45 ` [Bug tree-optimization/105384] " pinskia at gcc dot gnu.org
  2022-04-25 19:46 ` pinskia at gcc dot gnu.org
@ 2022-04-25 19:52 ` zsojka at seznam dot cz
  2022-04-25 20:44 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2022-04-25 19:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

--- Comment #3 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Andrew Pinski from comment #2)
> Can you try the one that is downloaded via contrib/download_pre*.

The you for the comment. The versions I am using are:
[ebuild   R    ] dev-libs/gmp-6.2.1-r2 
[ebuild   R    ] dev-libs/mpfr-4.1.0_p13-r1 
[ebuild   R    ] dev-libs/isl-0.24-r2 
[ebuild   R    ] dev-libs/mpc-1.2.1 

They match the version downloaded by contrib/download_pre*, but might contain
gentoo-specific patches:

gmp-6.2.1.tar.bz2: OK
mpfr-4.1.0.tar.bz2: OK
mpc-1.2.1.tar.gz: OK
isl-0.24.tar.bz2: OK

I will try with the vanilla versions.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2022-04-25 19:52 ` zsojka at seznam dot cz
@ 2022-04-25 20:44 ` marxin at gcc dot gnu.org
  2022-04-26  6:52 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-04-25 20:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-04-25
             Status|UNCONFIRMED                 |NEW
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
I can confirm that with system libraries (likely latest releases).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2022-04-25 20:44 ` marxin at gcc dot gnu.org
@ 2022-04-26  6:52 ` rguenth at gcc dot gnu.org
  2022-04-26  7:37 ` zsojka at seznam dot cz
  2022-04-26 18:04 ` joseph at codesourcery dot com
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-26  6:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The bessel functions are known to take a lot of time, there are (fixed?) older
bugreports about those and we do take some measures to speed up the
computation.
We might want to give up the idea on producing correctly rounded results and
simply invoke the host library routines here ...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2022-04-26  6:52 ` rguenth at gcc dot gnu.org
@ 2022-04-26  7:37 ` zsojka at seznam dot cz
  2022-04-26 18:04 ` joseph at codesourcery dot com
  6 siblings, 0 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2022-04-26  7:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

--- Comment #6 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Richard Biener from comment #5)
> The bessel functions are known to take a lot of time, there are (fixed?)
> older bugreports about those and we do take some measures to speed up the
> computation.
> We might want to give up the idea on producing correctly rounded results and
> simply invoke the host library routines here ...

$ cat testcase.c 
double
foo(double a, double b)
{
  return __builtin_yn(a, b);
}
double
bar(double a, double b)
{
  return __builtin_jn(a, b);
}
int main()
{
  foo(0x220f0985, 0xbc7bc234);
  bar(4292622104, 0xff00ff00ff00ff00);
  return 0;
}
$ gcc testcase.c -lm -O1
$ time ./a.out 

real    0m2.825s
user    0m2.815s
sys     0m0.010s

It takes quite some time at runtime, but the compilation time evaluation takes
several magnitudes more time (PR105384) and/or memory (PR105385).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/105384] compilation never (?) finishes with __builtin_yn{,f,l} at -O and above
  2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2022-04-26  7:37 ` zsojka at seznam dot cz
@ 2022-04-26 18:04 ` joseph at codesourcery dot com
  6 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2022-04-26 18:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105384

--- Comment #7 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Using host libm routines is a bad idea, that would make the generated code 
depend on the host libm and processor.  Having a cut-off to avoid constant 
folding these functions for n >= 128 might make sense (that cut-off is 
chosen as the one beyond which the ISO 24747 versions of the functions, 
and the versions in the standard C++ library, have implementation-defined 
behavior).

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-04-26 18:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 19:42 [Bug tree-optimization/105384] New: compilation never (?) finishes with __builtin_yn{,f,l} at -O and above zsojka at seznam dot cz
2022-04-25 19:45 ` [Bug tree-optimization/105384] " pinskia at gcc dot gnu.org
2022-04-25 19:46 ` pinskia at gcc dot gnu.org
2022-04-25 19:52 ` zsojka at seznam dot cz
2022-04-25 20:44 ` marxin at gcc dot gnu.org
2022-04-26  6:52 ` rguenth at gcc dot gnu.org
2022-04-26  7:37 ` zsojka at seznam dot cz
2022-04-26 18:04 ` joseph at codesourcery dot com

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).