From: Thomas Koenig <tkoenig@netcologne.de>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [patch, fortran, committed] Fix regression PR 48412
Date: Mon, 04 Apr 2011 20:26:00 -0000 [thread overview]
Message-ID: <4D9A2983.4020502@netcologne.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 678 bytes --]
Hello world,
I have committed the attached patch to trunk as obvious after
regression-testing. The problem was that the assignment statements had
been added in the wrong order, which was fixed by reversing the order of
the loops looking for common function calls in cfe_expr_0.
Many thanks to Joost for finding the bug in the first place and for
reducing that far!
Thomas
2011-04-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48412
* frontend-passes (cfe_expr_0): Reverse the order of going
through the loops.
2011-04-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/48412
* function_optimize_4.f90: New test.
[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 835 bytes --]
Index: frontend-passes.c
===================================================================
--- frontend-passes.c (Revision 171913)
+++ frontend-passes.c (Arbeitskopie)
@@ -295,16 +295,16 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
gfc_expr_walker (e, cfe_register_funcs, NULL);
- /* Walk backwards through all the functions to make sure we
- catch the leaf functions first. */
- for (i=expr_count-1; i>=1; i--)
+ /* Walk through all the functions. */
+
+ for (i=1; i<expr_count; i++)
{
/* Skip if the function has been replaced by a variable already. */
if ((*(expr_array[i]))->expr_type == EXPR_VARIABLE)
continue;
newvar = NULL;
- for (j=i-1; j>=0; j--)
+ for (j=0; j<i; j++)
{
if (gfc_dep_compare_functions(*(expr_array[i]),
*(expr_array[j]), true) == 0)
[-- Attachment #3: function_optimize_4.f90 --]
[-- Type: text/plain, Size: 408 bytes --]
! { dg-do run }
! { dg-options "-O" }
! PR 48412 - function elimination got temporary varibles in the wrong order.
! Test case contributed by Joost VandeVondele.
INTEGER FUNCTION S1(m,ma,lx)
INTEGER :: m,ma,lx
IF (((m < 0).AND.(MODULO(ABS(ma-lx),2) == 1)).OR.&
((m > 0).AND.(MODULO(ABS(ma-lx),2) == 0))) THEN
S1=1
ELSE
S1=0
ENDIF
END FUNCTION
INTEGER :: s1
IF (S1(1,2,1).NE.0) CALL ABORT()
END
reply other threads:[~2011-04-04 20:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D9A2983.4020502@netcologne.de \
--to=tkoenig@netcologne.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).