public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran] Make -Ofast imply -fstack-arrays
@ 2011-05-14 14:40 Tobias Burnus
  2011-05-14 14:43 ` Janne Blomqvist
  2011-05-14 16:42 ` Toon Moene
  0 siblings, 2 replies; 3+ messages in thread
From: Tobias Burnus @ 2011-05-14 14:40 UTC (permalink / raw)
  To: gcc patches, gfortran

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

As title says: Make -Ofast imply -fstack-arrays

(For Polyhedron shows, -fstack-arrays improves performance by 7% to 10%. 
Cf. 
https://userpage.physik.fu-berlin.de/~tburnus/gcc-trunk/benchmark/iff/#rt )

Build on x86-64-linux.
OK for the trunk?

Tobias

[-- Attachment #2: Ofast-stack-arrays.diff --]
[-- Type: text/x-patch, Size: 2512 bytes --]

2011-05-14  Tobias Burnus  <burnus@net-b.de>

	* doc/invoke.texi (-Ofast): Also enables -fstack-arrays.

2011-05-14  Tobias Burnus  <burnus@net-b.de>

	* options.c (gfc_init_options, gfc_post_options): Enable
	-fstack-arrays by default if -Ofast is used.
	* invoke.texi (-fstack-arrays): Document this.

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index aee1e6b..6ed289e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -6000,7 +6000,7 @@ Disregard strict standards compliance.  @option{-Ofast} enables all
 @option{-O3} optimizations.  It also enables optimizations that are not
 valid for all standard compliant programs.
 It turns on @option{-ffast-math} and the Fortran-specific
-@option{-fno-protect-parens}.
+@option{-fno-protect-parens} and @option{-fstack-arrays}.
 
 If you use multiple @option{-O} options, with or without level numbers,
 the last such option is the one that is effective.
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 9f02239..f0ee096 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -1385,7 +1385,9 @@ The default value for @var{n} is 32768.
 Adding this option will make the fortran compiler put all local arrays,
 even those of unknown size onto stack memory.  If your program uses very
 large local arrays it's possible that you'll have to extend your runtime
-limits for stack memory on some operating systems.
+limits for stack memory on some operating systems. This flag is enabled
+by default at optimization level @option{-Ofast}.
+
 
 @item -fpack-derived
 @opindex @code{fpack-derived}
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index c67d109..8e352ae 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -125,7 +125,7 @@ gfc_init_options (unsigned int decoded_options_count,
 
   /* Default value of flag_max_stack_var_size is set in gfc_post_options.  */
   gfc_option.flag_max_stack_var_size = -2;
-  gfc_option.flag_stack_arrays = 0;
+  gfc_option.flag_stack_arrays = -1;
 
   gfc_option.flag_range_check = 1;
   gfc_option.flag_pack_derived = 0;
@@ -275,6 +275,9 @@ gfc_post_options (const char **pfilename)
   if (gfc_option.flag_protect_parens == -1)
     gfc_option.flag_protect_parens = !optimize_fast;
 
+  if (gfc_option.flag_stack_arrays == -1)
+    gfc_option.flag_stack_arrays = optimize_fast;
+
   /* By default, disable (re)allocation during assignment for -std=f95,
      and enable it for F2003/F2008/GNU/Legacy. */
   if (gfc_option.flag_realloc_lhs == -1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] Make -Ofast imply -fstack-arrays
  2011-05-14 14:40 [Patch, Fortran] Make -Ofast imply -fstack-arrays Tobias Burnus
@ 2011-05-14 14:43 ` Janne Blomqvist
  2011-05-14 16:42 ` Toon Moene
  1 sibling, 0 replies; 3+ messages in thread
From: Janne Blomqvist @ 2011-05-14 14:43 UTC (permalink / raw)
  To: Tobias Burnus; +Cc: gcc patches, gfortran

On Sat, May 14, 2011 at 10:14, Tobias Burnus <burnus@net-b.de> wrote:
> As title says: Make -Ofast imply -fstack-arrays
>
> (For Polyhedron shows, -fstack-arrays improves performance by 7% to 10%. Cf.
> https://userpage.physik.fu-berlin.de/~tburnus/gcc-trunk/benchmark/iff/#rt )
>
> Build on x86-64-linux.
> OK for the trunk?

Ok.



-- 
Janne Blomqvist

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, Fortran] Make -Ofast imply -fstack-arrays
  2011-05-14 14:40 [Patch, Fortran] Make -Ofast imply -fstack-arrays Tobias Burnus
  2011-05-14 14:43 ` Janne Blomqvist
@ 2011-05-14 16:42 ` Toon Moene
  1 sibling, 0 replies; 3+ messages in thread
From: Toon Moene @ 2011-05-14 16:42 UTC (permalink / raw)
  To: gcc-patches

On 05/14/2011 09:14 AM, Tobias Burnus wrote:

> As title says: Make -Ofast imply -fstack-arrays

I haven't commented on this before, but everyone should realize that 
automatic arrays were allocated on the stack *always* by g77.

I never even bothered to study how gfortran did it, because I assumed it 
would just have copied g77's behavior.

Duh.

-- 
Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/; weather: http://moene.org/~hirlam/
Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-14 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-14 14:40 [Patch, Fortran] Make -Ofast imply -fstack-arrays Tobias Burnus
2011-05-14 14:43 ` Janne Blomqvist
2011-05-14 16:42 ` Toon Moene

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).