public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization
@ 2012-04-27 23:30 jpsinthemix at verizon dot net
2012-04-28 20:42 ` [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize burnus at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: jpsinthemix at verizon dot net @ 2012-04-27 23:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
Bug #: 53148
Summary: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic
function parsing on labeled statements when compiled
w/optimization
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jpsinthemix@verizon.net
Created attachment 27256
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27256
Compilation and .s files for -O0 and -O2 optimizations
Hi,
There appears to be a gcc/gfortran-4.7.0 regression occurring for -O
optimizations greater than -O0 related to the parsing of labeled statements
containing expressions with repeated function calls. For example, a statement
like:
10 x = dble(y)*dble(y)
will generate a compiler warning, similar to
label_opt_issue.f:38:0: warning: '__var_1' is used uninitialized in this
function [-Wuninitialized]
and at runtime, the expression dble(y)*dble(y) will always evaluate to 0,
regardless of the value of y.
Expected results are obtained when the code is compiled with default/no
optimization, but failure occurs when compiling with -O1 and above. There is
nothing special about the use of intrinsic DBLE here, the same behavior occurs
for other intrinsic functions (user-defined functions work as expected). In
addition, if a more complicated expression is used, for example,
10 x = (1.d0 + exp(y)*exp(y))/z
then the same compilation warning occurs, and the value of x is evaluated as
x = (1 + 0)/z = 1/z
that is, exp(y)*exp(y) evaluates to 0, regardless of y.
This issue is not present in gcc/gfortran-4.6.3. The following program
demonstrates the issue:
C label_opt_issue.f
program main
real x
double precision xsq
double precision test_func
double precision work_around
x = 5.
xsq = test_func(x)
write(*,*) "function x: ", x, " x*x: ", xsq
call test_subr(x,xsq)
write(*,*) "subroutine x: ", x, " x*x: ", xsq
xsq = work_around(x)
write(*,*) "expected x: ", x, " x*x: ", xsq
end program
subroutine test_subr(x,xsq)
real x
double precision xsq
intrinsic dble
goto 10
10 xsq = dble(x)*dble(x)
return
end subroutine
double precision function test_func(x)
real x
intrinsic dble
goto 10
10 test_func = dble(x)*dble(x)
return
end function
double precision function work_around(x)
real x
intrinsic dble
goto 10
10 continue
work_around = dble(x)*dble(x)
return
end function
Demonstration code output:
With -O1 to -O3 optimization:
$ ./label_opt_issue
function x: 5.00000000 x*x: 0.0000000000000000
subroutine x: 5.00000000 x*x: 0.0000000000000000
expected x: 5.00000000 x*x: 25.000000000000000
With default optimization:
$ ./label_opt_issue
function x: 5.00000000 x*x: 25.000000000000000
subroutine x: 5.00000000 x*x: 25.000000000000000
expected x: 5.00000000 x*x: 25.000000000000000
I have attached the label_opt_issue.f compilation logs and temp *.s files for
for two cases: default optimization and -O2 optimization.
I came across this issue building and testing SCIPY; one test failed which
really should not have, and that lead me to a fortran routine using DBLE in the
manner above which always evaluated to 0.
System info:
=== gcc/gfortran version/options/system type:
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /home/bld/gcc-4.7.0-jps_src/gcc-4.7.0/configure --prefix=/usr
--libexecdir=/usr/lib --with-gmp=/usr --with-mpfr=/usr --with-system-zlib
--enable-shared --enable-checking=release --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --disable-bootstrap
--enable-languages=c,c++,fortran --infodir=/usr/share/info
--mandir=/usr/share/man
Thread model: posix
gcc version 4.7.0 (GCC)
system: Linux b-movie 3.3.3 #1 Sun Apr 22 21:11:23 EDT 2012 i686 GNU/Linux
glibc: 2.15
thanks for your time,
John
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
@ 2012-04-28 20:42 ` burnus at gcc dot gnu.org
2012-04-29 7:04 ` tkoenig at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-04-28 20:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |wrong-code
Last reconfirmed| |2012-04-28
Component|libfortran |fortran
CC| |burnus at gcc dot gnu.org,
| |tkoenig at gcc dot gnu.org
Ever Confirmed|0 |1
Summary|[gcc/gfortran-4.7.0 |[4.7/4.8 Regression]
|Regression] Incorrect |Incorrect intrinsic
|intrinsic function parsing |function parsing on labeled
|on labeled statements when |statements when compiled w/
|compiled w/optimization |-ffrontend-optimize
Target Milestone|--- |4.7.1
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-04-28 20:41:18 UTC ---
Workaround: -fno-frontend-optimize
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
2012-04-28 20:42 ` [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize burnus at gcc dot gnu.org
@ 2012-04-29 7:04 ` tkoenig at gcc dot gnu.org
2012-04-29 7:12 ` tkoenig at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-04-29 7:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |tkoenig at gcc dot gnu.org
|gnu.org |
--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-04-29 07:03:25 UTC ---
I have a patch.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
2012-04-28 20:42 ` [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize burnus at gcc dot gnu.org
2012-04-29 7:04 ` tkoenig at gcc dot gnu.org
@ 2012-04-29 7:12 ` tkoenig at gcc dot gnu.org
2012-04-30 19:32 ` [Bug fortran/53148] [4.7 " tkoenig at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-04-29 7:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-04-29 07:12:10 UTC ---
Author: tkoenig
Date: Sun Apr 29 07:12:03 2012
New Revision: 186942
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186942
Log:
2012-04-29 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/53148
* frontend-passes.c (create_var): If the statement has a label,
put the label around the block.
2012-04-29 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/53148
* gfortran.dg/function_optimize_12.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/function_optimize_12.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/frontend-passes.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
` (2 preceding siblings ...)
2012-04-29 7:12 ` tkoenig at gcc dot gnu.org
@ 2012-04-30 19:32 ` tkoenig at gcc dot gnu.org
2012-04-30 19:35 ` tkoenig at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-04-30 19:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-04-30 19:31:24 UTC ---
Author: tkoenig
Date: Mon Apr 30 19:31:13 2012
New Revision: 186999
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186999
Log:
2012-04-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/53148
Backport from trunk
* frontend-passes.c (create_var): If the statement has a label,
put the label around the block.
2012-04-30 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/53148
Backport from trunk
* gfortran.dg/function_optimize_12.f90: New test.
Added:
branches/gcc-4_7-branch/gcc/testsuite/gfortran.dg/function_optimize_12.f90
Modified:
branches/gcc-4_7-branch/gcc/fortran/ChangeLog
branches/gcc-4_7-branch/gcc/fortran/frontend-passes.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
` (3 preceding siblings ...)
2012-04-30 19:32 ` [Bug fortran/53148] [4.7 " tkoenig at gcc dot gnu.org
@ 2012-04-30 19:35 ` tkoenig at gcc dot gnu.org
2012-04-30 23:47 ` jpsinthemix at verizon dot net
2012-05-21 15:13 ` jsm28 at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-04-30 19:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-04-30 19:34:23 UTC ---
Fixed on trunk and 4.7.
Closing.
Thanks a lot for the bug report!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
` (4 preceding siblings ...)
2012-04-30 19:35 ` tkoenig at gcc dot gnu.org
@ 2012-04-30 23:47 ` jpsinthemix at verizon dot net
2012-05-21 15:13 ` jsm28 at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jpsinthemix at verizon dot net @ 2012-04-30 23:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
--- Comment #6 from John Stanley <jpsinthemix at verizon dot net> 2012-04-30 23:47:03 UTC ---
(In reply to comment #5)
> Fixed on trunk and 4.7.
>
> Closing.
>
> Thanks a lot for the bug report!
I rebuilt gcc with cherry-picked patches and all look good. Really appreciate
the super-fast response and fix.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/53148] [4.7 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
` (5 preceding siblings ...)
2012-04-30 23:47 ` jpsinthemix at verizon dot net
@ 2012-05-21 15:13 ` jsm28 at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2012-05-21 15:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53148
--- Comment #7 from Joseph S. Myers <jsm28 at gcc dot gnu.org> 2012-05-21 14:42:40 UTC ---
Author: jsm28
Date: Mon May 21 14:42:26 2012
New Revision: 187718
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187718
Log:
PR c/53148
* c-typeck.c (build_conditional_expr): Remove C_MAYBE_CONST_EXPR
from folded operands before wrapping another around the
conditional expression.
testsuite:
* gcc.c-torture/compile/pr53418-1.c,
gcc.c-torture/compile/pr53418-2.c: New tests.
Added:
trunk/gcc/testsuite/gcc.c-torture/compile/pr53418-1.c
trunk/gcc/testsuite/gcc.c-torture/compile/pr53418-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/c-typeck.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-05-21 15:13 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27 23:30 [Bug libfortran/53148] New: [gcc/gfortran-4.7.0 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/optimization jpsinthemix at verizon dot net
2012-04-28 20:42 ` [Bug fortran/53148] [4.7/4.8 Regression] Incorrect intrinsic function parsing on labeled statements when compiled w/ -ffrontend-optimize burnus at gcc dot gnu.org
2012-04-29 7:04 ` tkoenig at gcc dot gnu.org
2012-04-29 7:12 ` tkoenig at gcc dot gnu.org
2012-04-30 19:32 ` [Bug fortran/53148] [4.7 " tkoenig at gcc dot gnu.org
2012-04-30 19:35 ` tkoenig at gcc dot gnu.org
2012-04-30 23:47 ` jpsinthemix at verizon dot net
2012-05-21 15:13 ` jsm28 at gcc dot gnu.org
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).