* [fortran,patch] Getting rid of an ICE on ISNAN
@ 2007-10-29 20:42 François-Xavier Coudert
2007-10-30 12:11 ` Richard Guenther
0 siblings, 1 reply; 3+ messages in thread
From: François-Xavier Coudert @ 2007-10-29 20:42 UTC (permalink / raw)
To: GFortran, gcc-patches list; +Cc: Andrew Pinski, Richard Guenther
[-- Attachment #1: Type: text/plain, Size: 556 bytes --]
When generating code for ISNAN(real-constant), we call
build_call_expr() and get back an expression inside a NOP_EXPR, which
is not expected, and leads to an ICE further in the middle-end. Using
STRIP_TYPE_NOPS gets rid of the problem, even though it might be
better to fix it in the middle-end. Andrew, Richard, you had ideas
about this, do you want me to keep the PR open after this workaround
is committed, and change its component to "middle-end"?
Bootstrapped and regtested, with type checking, on x86_64-linux. OK to commit?
FX
:ADDPATCH fortran:
[-- Attachment #2: isnan.ChangeLog --]
[-- Type: application/octet-stream, Size: 302 bytes --]
2007-10-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/33596
* trans-intrinsic.c (gfc_conv_intrinsic_isnan): Strip NOP_EXPR
from the result of build_call_expr.
2007-10-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/33596
* gfortran.dg/isnan_2.f90: New test.
[-- Attachment #3: isnan.diff --]
[-- Type: application/octet-stream, Size: 1171 bytes --]
Index: gcc/fortran/trans-intrinsic.c
===================================================================
--- gcc/fortran/trans-intrinsic.c (revision 129647)
+++ gcc/fortran/trans-intrinsic.c (working copy)
@@ -2757,6 +2757,7 @@ gfc_conv_intrinsic_isnan (gfc_se * se, g
gfc_conv_intrinsic_function_args (se, expr, &arg, 1);
se->expr = build_call_expr (built_in_decls[BUILT_IN_ISNAN], 1, arg);
+ STRIP_TYPE_NOPS (se->expr);
se->expr = fold_convert (gfc_typenode_for_spec (&expr->ts), se->expr);
}
Index: gcc/testsuite/gfortran.dg/isnan_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/isnan_2.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/isnan_2.f90 (revision 0)
@@ -0,0 +1,17 @@
+! Test for the ISNAN intrinsic on constants
+!
+! { dg-do run }
+! { dg-options "-fno-range-check" }
+! { dg-options "-fno-range-check -pedantic-errors -mieee" { target sh*-*-* } }
+!
+ implicit none
+ character(len=1) :: s
+ write(s,'(L1)') isnan(0.)
+ if (s /= 'F') call abort
+
+ write(s,'(L1)') isnan(exp(huge(0.)))
+ if (s /= 'F') call abort
+
+ write(s,'(L1)') isnan(0./0.)
+ if (s /= 'T') call abort
+end
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [fortran,patch] Getting rid of an ICE on ISNAN
2007-10-29 20:42 [fortran,patch] Getting rid of an ICE on ISNAN François-Xavier Coudert
@ 2007-10-30 12:11 ` Richard Guenther
2007-10-30 22:23 ` FX Coudert
0 siblings, 1 reply; 3+ messages in thread
From: Richard Guenther @ 2007-10-30 12:11 UTC (permalink / raw)
To: François-Xavier Coudert; +Cc: GFortran, gcc-patches list, Andrew Pinski
[-- Attachment #1: Type: TEXT/PLAIN, Size: 759 bytes --]
On Mon, 29 Oct 2007, François-Xavier Coudert wrote:
> When generating code for ISNAN(real-constant), we call
> build_call_expr() and get back an expression inside a NOP_EXPR, which
> is not expected, and leads to an ICE further in the middle-end. Using
> STRIP_TYPE_NOPS gets rid of the problem, even though it might be
> better to fix it in the middle-end. Andrew, Richard, you had ideas
> about this, do you want me to keep the PR open after this workaround
> is committed, and change its component to "middle-end"?
>
> Bootstrapped and regtested, with type checking, on x86_64-linux. OK to commit?
> FX
I think this is ok, even from a middle-end point of view (that is, until
we disentangle middle-end fold from frontend fold).
Richard.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [fortran,patch] Getting rid of an ICE on ISNAN
2007-10-30 12:11 ` Richard Guenther
@ 2007-10-30 22:23 ` FX Coudert
0 siblings, 0 replies; 3+ messages in thread
From: FX Coudert @ 2007-10-30 22:23 UTC (permalink / raw)
To: Richard Guenther; +Cc: GFortran, gcc-patches list, Andrew Pinski
> I think this is ok, even from a middle-end point of view (that is,
> until
> we disentangle middle-end fold from frontend fold).
Given Richard's opinion and the fact that it's a one-liner, I've
committed this patch as rev. 129782.
FX
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-30 21:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-29 20:42 [fortran,patch] Getting rid of an ICE on ISNAN François-Xavier Coudert
2007-10-30 12:11 ` Richard Guenther
2007-10-30 22:23 ` FX Coudert
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).