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

--- Comment #19 from anlauf at gcc dot gnu.org ---
(In reply to r...@cebitec.uni-bielefeld.de from comment #14)
> > --- Comment #13 from anlauf at gcc dot gnu.org ---
> > This may lead to a total mess, and I am unable to test it, but can you try:
> 
> I just ran bootstraps on both sparc-sun-solaris2.11 and
> i386-pc-solaris2.11.  x86 results are unchanged, but sparc is completely
> miserable:

OK, thanks.  Scrap the patch from comment#13.  Let's try using long double
when TYPE_PRECISION (long_double_type_node) is big enough for the conversion:

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 32fe9886c57..c508a4faedb 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -395,6 +395,13 @@ build_round_expr (tree arg, tree restype)
     fn = builtin_decl_for_precision (BUILT_IN_LROUND, argprec);
   else if (resprec <= LONG_LONG_TYPE_SIZE)
     fn = builtin_decl_for_precision (BUILT_IN_LLROUND, argprec);
+  else if (resprec == TYPE_PRECISION (long_double_type_node)
+          && resprec >= argprec)
+    {
+      int kind = TYPE_PRECISION (long_double_type_node) / 8;
+      arg = fold_convert (long_double_type_node, arg);
+      fn = gfc_builtin_decl_for_float_kind (BUILT_IN_ROUND, kind);
+    }
   else if (resprec >= argprec && resprec == 128)
     {
       /* Search for a real kind suitable as temporary for conversion.  */

This should have no effect on x86.

I may work on SPARC; could you please test for me?

It will not work on POWER given comment#15 by Peter.
However, the prints by Peter suggest that IBM's long double could be a
usable type.  So if this works on SPARC, one could adapt it to POWER,
but we'd need also a slightly adapted testcase that runs only on POWER,
while the original one is for IEEE128 platforms only.

Reply via email to