g++ -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I/opt/gnu/gcc/gmp/include -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o sreal.o -MT sreal.o -MMD -MP -MF ./.deps/sreal.TPo ../../gcc/gcc/sreal.c ../../gcc/gcc/sreal.c: In member function 'double sreal::to_double() const': ../../gcc/gcc/sreal.c:125:23: error: 'exp2' was not declared in this scope make[3]: *** [sreal.o] Error 1 Maybe fallback to pow?
The exp2 call was substituted wiht scalbln as part of PR64503 fix. Is this still an issue?
On 2015-01-09, at 7:35 AM, ubizjak at gmail dot com wrote: > The exp2 call was substituted wiht scalbln as part of PR64503 fix. > > > > Is this still an issue? I will check but it would appear that it's still and issue. scalbln is not available. What is available is ldexp and the size of int is the same as size of long. Dave -- John David Anglin dave.anglin@bell.net
In libgfortran/intrinsics/c99_functions.c, scalbn is implemented like this: double scalbn (double x, int y) { #if (FLT_RADIX == 2) && defined(HAVE_LDEXP) return ldexp (x, y); #else return x * pow (FLT_RADIX, y); #endif } Maybe something similar could be used here. If pow is not OK, something like this could be used: return (y >= 0) ? x * (1 << y) : x / (1 << (-y)); (assuming that shift will not cause overflow). BTW, what if FLT_RADIX != 2?
(In reply to Mikhail Maltsev from comment #3) > In libgfortran/intrinsics/c99_functions.c, scalbn is implemented like this: > > double > scalbn (double x, int y) You should be extra careful here, we are using scalbln to avoid overflows. Please see PR64503, there are some ipa tests in the testsuite (e.g. gcc.dg/ipa/iinline-4.c) that report -inf for estimated badness when other functions are used.
On 2015-01-09 2:31 PM, ubizjak at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64370 > > > > --- Comment #4 from Uroš Bizjak <ubizjak at gmail dot com> --- > > (In reply to Mikhail Maltsev from comment #3) > >> In libgfortran/intrinsics/c99_functions.c, scalbn is implemented like thi > s: > >> double >> scalbn (double x, int y) > > > You should be extra careful here, we are using scalbln to avoid overflows. > > > Please see PR64503, there are some ipa tests in the testsuite (e.g. > > gcc.dg/ipa/iinline-4.c) that report -inf for estimated badness when other > > functions are used. The change to using scalbln breaks hppa*-hpux11* as well: g++ -c -g -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables - W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format- attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wn o-overlength-strings -fno-common -DHAVE_CONFIG_H -I. -I. -I../../gcc/gcc -I../. ./gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include -I/opt/ gnu/gcc/gmp/include -I../../gcc/gcc/../libdecnumber -I../../gcc/gcc/../libdecnu mber/dpd -I../libdecnumber -I../../gcc/gcc/../libbacktrace -o sreal.o -MT srea l.o -MMD -MP -MF ./.deps/sreal.TPo ../../gcc/gcc/sreal.c ../../gcc/gcc/sreal.c: In member function 'double sreal::to_double() const': ../../gcc/gcc/sreal.c:125:30: error: 'scalbln' was not declared in this scope val = scalbln (val, m_exp); I am puzzled why scalbln was used as m_exp has type "signed int". The code also seems to be specific to a radix of 2. So, ldexp (x, y) or x * pow (2, y) seem like the correct functions to use. Also note that an int type should hold the full range of exponents for double on every machine that I'm aware of, so it doesn't seem like there is any benefit in using scalbln over ldexp. I have read that there are problems with overflow detection on alpha. So, is that the issue? Dave
Do you have ldexp on HPUX? Asking because that is used in jcf-dump already...
(In reply to dave.anglin from comment #5) > > I have read that there are problems with overflow detection on alpha. > So, is that the issue? The issue us that -inf will ICE with FP exception on alpha. I don't think -inf (which is otherwise produced on other targets) is valid result, and using scalbln avoids it.
On 2015-01-12, at 6:09 AM, jakub at gcc dot gnu.org wrote: > Do you have ldexp on HPUX? Asking because that is used in jcf-dump already... Yes, it's available on hpux10.20 and hpux11. Dave -- John David Anglin dave.anglin@bell.net
Author: jakub Date: Mon Jan 12 20:30:09 2015 New Revision: 219489 URL: https://gcc.gnu.org/viewcvs?rev=219489&root=gcc&view=rev Log: PR other/64370 * sreal.c (sreal::to_double): Use ldexp instead of scalbnl. Modified: trunk/gcc/ChangeLog trunk/gcc/sreal.c
Assuming fixed then.
(In reply to Jakub Jelinek from comment #10) > Assuming fixed then. ldexp is also OK for alpha.