diff mbox

[doc,+,fortran] Make -Ofast honor -fmax-stack-var-size

Message ID bb3ca172-f56b-96f6-6b28-b88b56af3d9e@netcologne.de
State New
Headers show

Commit Message

Thomas Koenig Aug. 4, 2017, 7:32 p.m. UTC
Am 04.08.2017 um 14:09 schrieb Thomas Koenig:
> Hello world,
> 
> the attached patch

This time, really attached, even with ChangeLog!

Regards

	Thomas

2017-08-04  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/68829
         * doc/invoke.texi: Document change in behvaior for -Ofast for
         Fortran.

2017-08-04  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/68829
         PR fortran/81701
         * options.c: Make -Ofast honor -fmax-stack-var-size.
         * invoke.texi: Document change.

2017-08-04  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR fortran/68829
         PR fortran/81701
         * gfortran.dg/o_fast_stacksize.90:  New test.


>makes -Ofast honor -fmax-stack-var-size, and adjusts
> the documentation in the gcc and fortran directories accordingly.
> This is done to alleviate PR 68829, to make it possible to run -Ofast
> with less stack usage.  I have also taken the opportunity to make
> it a bit clearer what -fstack-arrays actually does.
> 
> I intend to close PR 68829 once this is committed.
> 
> Regression-tested, plus doc changes tested with "make pdf" and
> "make dvi".
> 
> OK for trunk for
> 
> - the fortran subdirectory changes
> - the gcc doc changes (if the one above is approved)
> 
> ?
> 
> Regards
> 
>      Thomas
>

Comments

Jerry DeLisle Aug. 6, 2017, 4:54 p.m. UTC | #1
Looks OK, thanks.

Jerry

On 08/04/2017 12:32 PM, Thomas Koenig wrote:
> Am 04.08.2017 um 14:09 schrieb Thomas Koenig:
>> Hello world,
>>
>> the attached patch
> 
> This time, really attached, even with ChangeLog!
> 
> Regards
> 
>     Thomas
> 
> 2017-08-04  Thomas Koenig  <tkoenig@gcc.gnu.org>
> 
>         PR fortran/68829
>         * doc/invoke.texi: Document change in behvaior for -Ofast for
>         Fortran.
> 
> 2017-08-04  Thomas Koenig  <tkoenig@gcc.gnu.org>
> 
>         PR fortran/68829
>         PR fortran/81701
>         * options.c: Make -Ofast honor -fmax-stack-var-size.
>         * invoke.texi: Document change.
> 
> 2017-08-04  Thomas Koenig  <tkoenig@gcc.gnu.org>
> 
>         PR fortran/68829
>         PR fortran/81701
>         * gfortran.dg/o_fast_stacksize.90:  New test.
> 
> 
>> makes -Ofast honor -fmax-stack-var-size, and adjusts
>> the documentation in the gcc and fortran directories accordingly.
>> This is done to alleviate PR 68829, to make it possible to run -Ofast
>> with less stack usage.  I have also taken the opportunity to make
>> it a bit clearer what -fstack-arrays actually does.
>>
>> I intend to close PR 68829 once this is committed.
>>
>> Regression-tested, plus doc changes tested with "make pdf" and
>> "make dvi".
>>
>> OK for trunk for
>>
>> - the fortran subdirectory changes
>> - the gcc doc changes (if the one above is approved)
>>
>> ?
>>
>> Regards
>>
>>      Thomas
>>
>
diff mbox

Patch

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(Revision 250720)
+++ doc/invoke.texi	(Arbeitskopie)
@@ -7278,7 +7278,8 @@ 
 @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} and @option{-fstack-arrays}.
+@option{-fstack-arrays}, unless @option{-fmax-stack-var-size} is
+specified, and @option{-fno-protect-parens}.
 
 @item -Og
 @opindex Og
Index: fortran/invoke.texi
===================================================================
--- fortran/invoke.texi	(Revision 250791)
+++ fortran/invoke.texi	(Arbeitskopie)
@@ -1570,13 +1570,13 @@ 
 
 @item -fstack-arrays
 @opindex @code{fstack-arrays}
-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
+Adding this option will make the Fortran compiler put all arrays of
+unknown size and array temporaries onto stack memory.  If your program uses very
 large local arrays it is possible that you will have to extend your runtime
 limits for stack memory on some operating systems. This flag is enabled
-by default at optimization level @option{-Ofast}.
+by default at optimization level @option{-Ofast} unless
+@option{-fmax-stack-var-size} is specified.
 
-
 @item -fpack-derived
 @opindex @code{fpack-derived}
 @cindex structure packing
Index: fortran/options.c
===================================================================
--- fortran/options.c	(Revision 250720)
+++ fortran/options.c	(Arbeitskopie)
@@ -235,7 +235,9 @@ 
   if (flag_protect_parens == -1)
     flag_protect_parens = !optimize_fast;
 
-  if (flag_stack_arrays == -1)
+  /* -Ofast sets implies -fstack-arrays unless an explicit size is set for
+     stack arrays.  */
+  if (flag_stack_arrays == -1 && flag_max_stack_var_size == -2)
     flag_stack_arrays = optimize_fast;
 
   /* By default, disable (re)allocation during assignment for -std=f95,
@@ -380,6 +382,10 @@ 
       flag_max_stack_var_size = -1;
     }
 
+  /* Set flag_stack_arrays correctly.  */
+  if (flag_stack_arrays == -1)
+    flag_stack_arrays = 0;
+
   /* Set default.  */
   if (flag_max_stack_var_size == -2)
     flag_max_stack_var_size = 32768;