Hi,

On 08.03.21 17:25, Eric Botcazou wrote:
AFAICS the code in build_round_expr implicitly assumes that __float128 exists,
which is *not* the common case among 64-bit architectures since "long double"
is generally already 128-bit for them.

Crossref: Introduced by the Patch for PR96711, 
https://gcc.gnu.org/pipermail/fortran/2020-August/054920.html

Its testcase causes the fails/this PR, hence, gfortran.dg/pr96711.f90 is the
testcase for this patch.

Tested on x86-64/Linux and SPARC64/Linux, OK for the mainline?

2021-03-08  Eric Botcazou  <ebotca...@adacore.com>

      PR fortran/96983
      * trans-intrinsic.c (build_round_expr): Do not implicitly assume
      that __float128 is the 128-bit floating-point type.

I think it is a bad idea to hard-code the real type.
Does the following work for you? If so, I think that
patch is obvious and you can go ahead and commit it.

--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -407,7 +407,7 @@ build_round_expr (tree arg, tree restype)
       if (kind < 0)
        gfc_internal_error ("Could not find real kind with at least %d bits",
                            resprec);
-      arg = fold_convert (gfc_float128_type_node, arg);
+      arg = fold_convert (gfc_get_real_type (kind), arg);
       fn = gfc_builtin_decl_for_float_kind (BUILT_IN_ROUND, kind);
     }
   else

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf

Reply via email to