public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/39298] New: Optimize away only set but not used variable
@ 2009-02-25 9:12 burnus at gcc dot gnu dot org
2009-02-25 9:43 ` [Bug middle-end/39298] " rguenth at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-02-25 9:12 UTC (permalink / raw)
To: gcc-bugs
In the following Fortran program, the variable "foo" is never used, it is only
set.
Result: Using "gfortran -O3", "foo" is not optimized away.
Expected: "foo" is optimized away as it happens with "ifort -O2".
program a
implicit none
integer*8 it,two
parameter(it=1073741824,two=2)
complex foo(it*two-1)
foo(10)=1.
write(*,*) ''
end program a
--
Summary: Optimize away only set but not used variable
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
@ 2009-02-25 9:43 ` rguenth at gcc dot gnu dot org
2009-02-25 13:37 ` Andrew Thomas Pinski
2009-02-25 9:52 ` rguenth at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-25 9:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-02-25 09:43 -------
Is there a reason the Fortran frontend gives function local variables static
storage duration?
a ()
{
struct __st_parameter_dt dt_parm.1;
static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1};
static complex(kind=4) foo[2147483647];
<bb 2>:
_gfortran_set_options (8, &options.0);
foo[9] = __complex__ (1.0e+0, 0.0);
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2009-02-25 09:43:40
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
2009-02-25 9:43 ` [Bug middle-end/39298] " rguenth at gcc dot gnu dot org
@ 2009-02-25 9:52 ` rguenth at gcc dot gnu dot org
2009-02-25 10:21 ` burnus at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-25 9:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2009-02-25 09:51 -------
It works with it == 1024 in which case foo is not static.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
2009-02-25 9:43 ` [Bug middle-end/39298] " rguenth at gcc dot gnu dot org
2009-02-25 9:52 ` rguenth at gcc dot gnu dot org
@ 2009-02-25 10:21 ` burnus at gcc dot gnu dot org
2009-02-25 10:35 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-02-25 10:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2009-02-25 10:21 -------
> Is there a reason the Fortran frontend gives function local variables static
> storage duration?
For huge arrays, there is a problem if the memory is allocated on the stack, as
one quickly hits stack-size limits. Thus gfortran puts large local arrays in
static memory, except when a procedure can be called recursively/simultaneously
(RECURSIVE attribute, -frecursive, -fopenmp). The size for which this happens
is controlled by -fmax-stack-var-size=<n>.
Actually, I don't quite see why the "static" matters: As local variable it
cannot be accessed from elsewhere and if it is not accessed in the procedure
...
Additionally, C's main() and Fortran's PRORGRAM (= "MAIN__") are special
because they are only called once.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2009-02-25 10:21 ` burnus at gcc dot gnu dot org
@ 2009-02-25 10:35 ` burnus at gcc dot gnu dot org
2009-02-25 11:21 ` rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-02-25 10:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2009-02-25 10:35 -------
I did some testing with sunf95, icc and ifort.
sunf95 also puts the variable in .bss as gfortran does, while ifort puts it on
the stack (unless explicitly declared as static ["SAVE"]). If the variable is
static, neither of the compilers optimizes it away.
a) Why are static variables not optimized away? (Not even in main()/MAIN_?)
b) Is there something what one could do to get the advantage of not having huge
variables on the stack but still allowing to optimize the variable away?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2009-02-25 10:35 ` burnus at gcc dot gnu dot org
@ 2009-02-25 11:21 ` rguenth at gcc dot gnu dot org
2009-02-25 13:37 ` pinskia at gmail dot com
2009-02-27 0:01 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-02-25 11:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2009-02-25 11:21 -------
Optimizing dead local static variables requires special handling which probably
is not thought to be worth the trouble. If the variable is unused the
programmer can as well remove it.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:43 ` [Bug middle-end/39298] " rguenth at gcc dot gnu dot org
@ 2009-02-25 13:37 ` Andrew Thomas Pinski
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Thomas Pinski @ 2009-02-25 13:37 UTC (permalink / raw)
To: gcc-bugzilla; +Cc: gcc-bugs
Sent from my iPhone
On Feb 25, 2009, at 1:43 AM, "rguenth at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org
> wrote:
>
>
> ------- Comment #1 from rguenth at gcc dot gnu dot org 2009-02-25
> 09:43 -------
> Is there a reason the Fortran frontend gives function local
> variables static
> storage duration?
>
Yes, it is larger than the threshhold. Remember fortran has no
recursive functions except for the ones which marked as such.
> a ()
> {
> struct __st_parameter_dt dt_parm.1;
> static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1};
> static complex(kind=4) foo[2147483647];
>
> <bb 2>:
> _gfortran_set_options (8, &options.0);
> foo[9] = __complex__ (1.0e+0, 0.0);
>
>
> --
>
> rguenth at gcc dot gnu dot org changed:
>
> What |Removed |Added
> ---
> ---
> ----------------------------------------------------------------------
> Status|UNCONFIRMED |NEW
> Ever Confirmed|0 |1
> Last reconfirmed|0000-00-00 00:00:00 |2009-02-25 09:43:40
> date| |
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2009-02-25 11:21 ` rguenth at gcc dot gnu dot org
@ 2009-02-25 13:37 ` pinskia at gmail dot com
2009-02-27 0:01 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gmail dot com @ 2009-02-25 13:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pinskia at gmail dot com 2009-02-25 13:37 -------
Subject: Re: Optimize away only set but not used variable
Sent from my iPhone
On Feb 25, 2009, at 1:43 AM, "rguenth at gcc dot gnu dot org"
<gcc-bugzilla@gcc.gnu.org
> wrote:
>
>
> ------- Comment #1 from rguenth at gcc dot gnu dot org 2009-02-25
> 09:43 -------
> Is there a reason the Fortran frontend gives function local
> variables static
> storage duration?
>
Yes, it is larger than the threshhold. Remember fortran has no
recursive functions except for the ones which marked as such.
> a ()
> {
> struct __st_parameter_dt dt_parm.1;
> static integer(kind=4) options.0[8] = {68, 255, 0, 0, 0, 1, 0, 1};
> static complex(kind=4) foo[2147483647];
>
> <bb 2>:
> _gfortran_set_options (8, &options.0);
> foo[9] = __complex__ (1.0e+0, 0.0);
>
>
> --
>
> rguenth at gcc dot gnu dot org changed:
>
> What |Removed |Added
> ---
> ---
> ----------------------------------------------------------------------
> Status|UNCONFIRMED |NEW
> Ever Confirmed|0 |1
> Last reconfirmed|0000-00-00 00:00:00 |2009-02-25 09:43:40
> date| |
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/39298] Optimize away only set but not used variable
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2009-02-25 13:37 ` pinskia at gmail dot com
@ 2009-02-27 0:01 ` pinskia at gcc dot gnu dot org
6 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-02-27 0:01 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pinskia at gcc dot gnu dot org 2009-02-27 00:00 -------
The fortran front-end needs to be able to tell the middle-end that the function
cannot be recursive and then the middle-end needs to use that info.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39298
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-02-27 0:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-25 9:12 [Bug middle-end/39298] New: Optimize away only set but not used variable burnus at gcc dot gnu dot org
2009-02-25 9:43 ` [Bug middle-end/39298] " rguenth at gcc dot gnu dot org
2009-02-25 13:37 ` Andrew Thomas Pinski
2009-02-25 9:52 ` rguenth at gcc dot gnu dot org
2009-02-25 10:21 ` burnus at gcc dot gnu dot org
2009-02-25 10:35 ` burnus at gcc dot gnu dot org
2009-02-25 11:21 ` rguenth at gcc dot gnu dot org
2009-02-25 13:37 ` pinskia at gmail dot com
2009-02-27 0:01 ` pinskia at gcc dot gnu dot 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).