public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, gcc doc + fortran] Make -Ofast honor -fmax-stack-var-size
@ 2017-08-04 12:09 Thomas Koenig
  2017-08-04 19:32 ` Thomas Koenig
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2017-08-04 12:09 UTC (permalink / raw)
  To: fortran, gcc-patches

Hello world,

the attached patch 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

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

* Re: [patch, gcc doc + fortran] Make -Ofast honor -fmax-stack-var-size
  2017-08-04 12:09 [patch, gcc doc + fortran] Make -Ofast honor -fmax-stack-var-size Thomas Koenig
@ 2017-08-04 19:32 ` Thomas Koenig
  2017-08-06 16:55   ` Jerry DeLisle
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2017-08-04 19:32 UTC (permalink / raw)
  To: fortran, gcc-patches

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

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
> 


[-- Attachment #2: p2.diff --]
[-- Type: text/x-patch, Size: 2351 bytes --]

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;

[-- Attachment #3: o_fast_stacksize.f90 --]
[-- Type: text/x-fortran, Size: 403 bytes --]

! { dg-do compile }
! { dg-options "-Ofast -fmax-stack-var-size=100 -fdump-tree-original" }
MODULE foo
CONTAINS
  SUBROUTINE mysum(a)
    INTEGER :: a(:)
    WRITE(6,*) SUM(a)
  END SUBROUTINE
END MODULE foo

USE foo
INTEGER, ALLOCATABLE :: a(:)
INTEGER, PARAMETER :: N=2**26 ! 256Mb array
ALLOCATE(a(N)) ; a=1
CALL mysum(a*a)
END
! { dg-final { scan-tree-dump-times "__builtin_malloc" 2 "original" } }

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

* Re: [patch, gcc doc + fortran] Make -Ofast honor -fmax-stack-var-size
  2017-08-04 19:32 ` Thomas Koenig
@ 2017-08-06 16:55   ` Jerry DeLisle
  0 siblings, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2017-08-06 16:55 UTC (permalink / raw)
  To: Thomas Koenig, fortran, gcc-patches

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

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

end of thread, other threads:[~2017-08-06 16:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-04 12:09 [patch, gcc doc + fortran] Make -Ofast honor -fmax-stack-var-size Thomas Koenig
2017-08-04 19:32 ` Thomas Koenig
2017-08-06 16:55   ` Jerry DeLisle

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