public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -freduce-all-givs and fortran
@ 2001-09-05  6:58 Jan Hubicka
  2001-09-06  1:33 ` Andreas Jaeger
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Hubicka @ 2001-09-05  6:58 UTC (permalink / raw)
  To: gcc-patches, gcc

Hi,
the fortran fontend enables by default -freduce-all-gics and
-fmove-all-movables.  This causes important problem on i386, where reducing all
givs brings too many temporary registers causing too many spills.

I don't follow the philosophy behind this decision.  What makes code generated
from fortran different?  It may be well possible that these options were
believed to help numeric code and waste integer one, but then it should be
documented and different option should be made for that, as numeric
programs are not limited to fortran.

Whats about simply dropping this?

Honza

Wed Sep  5 15:54:47 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* com.c (ffe_init_options): Do not default reducle_all_givs and
	move_all_movables.
	* invoke.texi (reduct-all-givs): No longer mention it is enabled
	by default.

Index: com.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/f/com.c,v
retrieving revision 1.127
diff -c -3 -p -r1.127 com.c
*** com.c	2001/07/20 13:27:40	1.127
--- com.c	2001/09/05 13:52:24
*************** static void
*** 14654,14661 ****
  ffe_init_options ()
  {
    /* Set default options for Fortran.  */
-   flag_move_all_movables = 1;
-   flag_reduce_all_givs = 1;
    flag_argument_noalias = 2;
    flag_errno_math = 0;
    flag_complex_divide_method = 1;
--- 14654,14659 ----
Index: invoke.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/doc/invoke.texi,v
retrieving revision 1.51
diff -c -3 -p -r1.51 invoke.texi
*** invoke.texi	2001/09/05 08:30:35	1.51
--- invoke.texi	2001/09/05 13:53:34
*************** outside the loop.
*** 3570,3579 ****
  Forces all general-induction variables in loops to be
  strength-reduced.
  
- @emph{Note:} When compiling programs written in Fortran,
- @option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled
- by default when you use the optimizer.
- 
  These options may generate better or worse code; results are highly
  dependent on the structure of loops within the source code.
  
--- 3570,3575 ----

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: -freduce-all-givs and fortran
@ 2001-09-05  7:19 Toon Moene
  2001-09-05  7:28 ` Jan Hubicka
  0 siblings, 1 reply; 13+ messages in thread
From: Toon Moene @ 2001-09-05  7:19 UTC (permalink / raw)
  To: jh; +Cc: gcc-patches, gcc

> the fortran fontend enables by default -freduce-all-gics and
> -fmove-all-movables.  This causes important problem on i386, where 
> reducing all givs brings too many temporary registers causing too 
> many spills.

That depends.  Lots of Fortran code is written in a way that would lead
to a *reduction* in the use of (integer) registers if you apply
-freduce-all-givs *and* fmove-all-movables.

The examples I have at home, but in general:

1. If you're dealing with nested loops over multi-rank arrays

and

2. The arrays are passed as actual arguments to the subroutine
   where the computation take place

then the combination -freduce-all-givs *and* fmove-all-movables is a win
(in number of integer registers used).

Of course, it would be better if loop.c contained code to detect this
itself, but this has turned out to be too hard (i.e. without a rewrite
of the loop optimising code).

Hope this helps,

--
Toon Moene, KNMI, PO Box 201, 3730 AE De Bilt, The Netherlands.
Tel. +31302206443, Fax +31302210407,  e-mail moene@knmi.nl
URL: http://www.knmi.nl/hirlam

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: -freduce-all-givs and fortran
@ 2001-09-06  2:58 Toon Moene
  2001-09-06  5:15 ` Andreas Jaeger
  0 siblings, 1 reply; 13+ messages in thread
From: Toon Moene @ 2001-09-06  2:58 UTC (permalink / raw)
  To: aj; +Cc: gcc-patches, gcc

> Using -fno-move-all-movables  -fno-reduce-all-givs is a 
> performance gain for 171.swim and 200.sixtrack but pessimizes 
> 172.[m]grid and 173.app[lu], 168.wupwise is indifferent.

Fascinating ... Do 171.swim and 200.sixtrack profit from loop
optimization *at all* ?  What happens if you use

-O2 -march=athlon -malign-double -fno-strength-reduce

?

--
Toon Moene, KNMI, PO Box 201, 3730 AE De Bilt, The Netherlands.
Tel. +31302206443, Fax +31302210407,  e-mail moene@knmi.nl
URL: http://www.knmi.nl/hirlam

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: -freduce-all-givs and fortran
@ 2001-09-06  8:46 Toon Moene
  2001-09-06 13:29 ` Toon Moene
  0 siblings, 1 reply; 13+ messages in thread
From: Toon Moene @ 2001-09-06  8:46 UTC (permalink / raw)
  To: aj; +Cc: jh, gcc-patches, gcc

Andreas wrote:

>    168.wupwise       1600     418         382*     1600     417         384*
>    171.swim          3100    1213         256*     3100    1040         298*
>    172.mgrid         1800    1017         177*     1800    1117         161*
>    173.applu         2100     759         277*     2100     813         258*
>    200.sixtrack      1100     577         191*     1100     534         206*

vs:

168.wupwise    444      360
171.swim      1012      306
172.mgrid     1036      174
173.applu      816      258
200.sixtrack   556      198

OK, so swim indeed gets most optimised "without" loop optimisation.

:-)

Someone who shall remain nameless showed me a (small) part of swim that
should fall wholly within the "fair use" clause.  I mailed it home to
study it there (where I actually have access to g77 :-)

However, I think I already know what's wrong ...

Sixtrack is more complicated, but as its source code is available
online, it might be possible to track that one down too.

"Back ... in the USSR !"

--
Toon Moene, KNMI, PO Box 201, 3730 AE De Bilt, The Netherlands.
Tel. +31302206443, Fax +31302210407,  e-mail moene@knmi.nl
URL: http://www.knmi.nl/hirlam

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: -freduce-all-givs and fortran
@ 2001-09-06 16:06 Dan Nicolaescu
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Nicolaescu @ 2001-09-06 16:06 UTC (permalink / raw)
  To: Richard Henderson, Toon Moene; +Cc: gcc-patches, gcc, aj, jh

How about the following code?

It shows another issue that occurs in swim from SPEC
(for the people that have access to SPEC, look at subroutine calc1)

      SUBROUTINE TEST
      PARAMETER(N=100,M=113)
      COMMON /COM/ A(N,M), B(N,M), C(N,M), D(N,M)
      DO I = 1, N
         DO J = 1, M
            A(I,J) = B(I+1,J) + C(I,J)
            D(I,J) = B(I+1,J) + C(I,J)
         ENDDO
      ENDDO
      END


      SUBROUTINE TEST2
      PARAMETER(N=100,M=113)
      COMMON /COM/ A(N,M), B(N,M), C(N,M), D(N,M)
      DO I = 1, N
         DO J = 1, M
            A(I,J) = B(I,J) + C(I,J)
            D(I,J) = B(I,J) + C(I,J)
         ENDDO
      ENDDO
      END


The innner loop for both functions as compiled by 3.0 -O2 on SPARC:

In the first subroutine:

.LL9:
        ld      [%i5], %f2
        addcc   %g1, -1, %g1
        ld      [%i2], %f3
        add     %i5, 400, %i5
        fadds   %f3, %f2, %f3
        st      %f3, [%i4]         <- after this store
        ld      [%i2], %f4         <- this is reloaded
        add     %i4, 400, %i4
        fadds   %f4, %f2, %f4
        add     %i2, 400, %i2
        st      %f4, [%i3]
        bpos    .LL9
        add     %i3, 400, %i3




In the second one everything is fine:


.LL22:
        ld      [%i5], %f2
        addcc   %g1, -1, %g1
        ld      [%i4], %f3
        add     %i5, 400, %i5
        fadds   %f2, %f3, %f2
        add     %i4, 400, %i4
        st      %f2, [%i3]
        st      %f2, [%i2]
        add     %i2, 400, %i2
        bpos    .LL22
        add     %i3, 400, %i3

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

end of thread, other threads:[~2001-09-06 16:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-05  6:58 -freduce-all-givs and fortran Jan Hubicka
2001-09-06  1:33 ` Andreas Jaeger
2001-09-06  7:11   ` Andreas Jaeger
2001-09-05  7:19 Toon Moene
2001-09-05  7:28 ` Jan Hubicka
2001-09-05  7:42   ` Toon Moene
2001-09-06  2:58 Toon Moene
2001-09-06  5:15 ` Andreas Jaeger
2001-09-06  5:25   ` Toon Moene
2001-09-06  8:46 Toon Moene
2001-09-06 13:29 ` Toon Moene
2001-09-06 14:47   ` Richard Henderson
2001-09-06 16:06 Dan Nicolaescu

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