* [patch] Fix PR fortran/96983
@ 2021-03-08 16:25 Eric Botcazou
2021-03-10 9:23 ` Tobias Burnus
0 siblings, 1 reply; 3+ messages in thread
From: Eric Botcazou @ 2021-03-08 16:25 UTC (permalink / raw)
To: fortran; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 476 bytes --]
Hi,
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.
Tested on x86-64/Linux and SPARC64/Linux, OK for the mainline?
2021-03-08 Eric Botcazou <ebotcazou@adacore.com>
PR fortran/96983
* trans-intrinsic.c (build_round_expr): Do not implicitly assume
that __float128 is the 128-bit floating-point type.
--
Eric Botcazou
[-- Attachment #2: pr96983.diff --]
[-- Type: text/x-patch, Size: 649 bytes --]
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 5c9258c65c3..ae359a07973 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -407,7 +407,10 @@ 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);
+ if (gfc_real16_is_float128)
+ arg = fold_convert (gfc_float128_type_node, arg);
+ else
+ arg = fold_convert (long_double_type_node, arg);
fn = gfc_builtin_decl_for_float_kind (BUILT_IN_ROUND, kind);
}
else
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix PR fortran/96983
2021-03-08 16:25 [patch] Fix PR fortran/96983 Eric Botcazou
@ 2021-03-10 9:23 ` Tobias Burnus
2021-03-10 11:34 ` Eric Botcazou
0 siblings, 1 reply; 3+ messages in thread
From: Tobias Burnus @ 2021-03-10 9:23 UTC (permalink / raw)
To: Eric Botcazou, fortran; +Cc: gcc-patches
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 <ebotcazou@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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix PR fortran/96983
2021-03-10 9:23 ` Tobias Burnus
@ 2021-03-10 11:34 ` Eric Botcazou
0 siblings, 0 replies; 3+ messages in thread
From: Eric Botcazou @ 2021-03-10 11:34 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches, fortran
> 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
Yes, it works fine on x86-64/Linux and SPARC64/Linux, applied, thanks.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-10 11:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 16:25 [patch] Fix PR fortran/96983 Eric Botcazou
2021-03-10 9:23 ` Tobias Burnus
2021-03-10 11:34 ` Eric Botcazou
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).