public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43072]  New: unneeded temporary (s=s+f(a))
@ 2010-02-15  7:37 jv244 at cam dot ac dot uk
  2010-02-15  7:51 ` [Bug fortran/43072] " pault at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-02-15  7:37 UTC (permalink / raw)
  To: gcc-bugs

Another case that doesn't need a temp:

MODULE M1
  PRIVATE
  REAL, PARAMETER :: c(2)=(/(i,i=1,2)/)
CONTAINS
  ! OK
  SUBROUTINE S0
    real :: r
     r=0
     r=S2(c)
  END SUBROUTINE S0
  ! NOT OK
  SUBROUTINE S1
    real :: r
     r=0
     r=r+S2(c)
  END SUBROUTINE S1

  FUNCTION S2(c)
     REAL, INTENT(IN) :: c(2)
     s2=0
  END FUNCTION S2
END MODULE M1

In S1, somehow it seems that 'c' is being packed if S2 is part of an expression


-- 
           Summary: unneeded temporary (s=s+f(a))
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
@ 2010-02-15  7:51 ` pault at gcc dot gnu dot org
  2010-02-15  7:58 ` jv244 at cam dot ac dot uk
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-02-15  7:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pault at gcc dot gnu dot org  2010-02-15 07:51 -------
Yes, indeed.

In fact, S2((/(real (i),i=1,2)/)) produces calls to pack and unpack in both S0
and S1.

I'll take a look at it.

Thanks

Paul


-- 

pault 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         |2010-02-15 07:51:01
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
  2010-02-15  7:51 ` [Bug fortran/43072] " pault at gcc dot gnu dot org
@ 2010-02-15  7:58 ` jv244 at cam dot ac dot uk
  2010-02-16 15:47 ` pault at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jv244 at cam dot ac dot uk @ 2010-02-15  7:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jv244 at cam dot ac dot uk  2010-02-15 07:58 -------
(In reply to comment #1)
> Yes, indeed.
> 
> In fact, S2((/(real (i),i=1,2)/)) produces calls to pack and unpack in both S0
> and S1.
> 
> I'll take a look at it.

You did beat me again, I wanted to file the following testcase, which I believe
is actually independent, but is similar to what you mentioned above:

MODULE M1
CONTAINS
  ! OK
  SUBROUTINE S0
     REAL, PARAMETER :: c(2)=(/1.0,2.0/)
     CALL S2(c)
  END SUBROUTINE S0

  ! NOT OK
  SUBROUTINE S1
     CALL S2((/1.0,2.0/))
  END SUBROUTINE S1

  SUBROUTINE S2(c)
     REAL, INTENT(IN) :: c(2)
  END SUBROUTINE S2

END MODULE M1

this 'S1' style appears also to be a rather common source of packs in CP2K


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
  2010-02-15  7:51 ` [Bug fortran/43072] " pault at gcc dot gnu dot org
  2010-02-15  7:58 ` jv244 at cam dot ac dot uk
@ 2010-02-16 15:47 ` pault at gcc dot gnu dot org
  2010-02-20 12:47 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-02-16 15:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2010-02-16 15:46 -------
(In reply to comment #2)

I have just patched a tree with the fix for PR36932 on an i686 at work.  None
of these temporaries appear!

Something is different between 32 and 64 bits..

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
                   ` (2 preceding siblings ...)
  2010-02-16 15:47 ` pault at gcc dot gnu dot org
@ 2010-02-20 12:47 ` pault at gcc dot gnu dot org
  2010-02-20 21:48 ` burnus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-02-20 12:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pault at gcc dot gnu dot org  2010-02-20 12:47 -------
Subject: Bug 43072

Author: pault
Date: Sat Feb 20 12:46:43 2010
New Revision: 156926

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156926
Log:
2010-02-20  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/36932
        PR fortran/36933
        PR fortran/43072
        PR fortran/43111
        * dependency.c (gfc_check_argument_var_dependency): Use enum
        value instead of arithmetic vaue for 'elemental'.
        (check_data_pointer_types): New function.
        (gfc_check_dependency): Call check_data_pointer_types.
        * trans-array.h : Change fourth argument of
        gfc_conv_array_parameter to boolean.
        * trans-array.c (gfc_conv_array_parameter): A contiguous array
        can be a dummy but it must not be assumed shape or deferred.
        Change fourth argument to boolean. Array constructor exprs will
        always be contiguous and do not need packing and unpacking.
        * trans-expr.c (gfc_conv_procedure_call): Clean up some white
        space and change fourth argument of gfc_conv_array_parameter
        to boolean.
        (gfc_trans_arrayfunc_assign): Change fourth argument of
        gfc_conv_array_parameter to boolean.
        * trans-io.c (gfc_convert_array_to_string): The same.
        * trans-intrinsic.c (gfc_conv_intrinsic_loc): The same.

2010-02-20  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/36932
        PR fortran/36933
        * gfortran.dg/dependency_26.f90: New test.

        PR fortran/43072
        * gfortran.dg/internal_pack_7.f90: New test.

        PR fortran/43111
        * gfortran.dg/internal_pack_8.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/dependency_26.f90
    trunk/gcc/testsuite/gfortran.dg/internal_pack_7.f90
    trunk/gcc/testsuite/gfortran.dg/internal_pack_8.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/dependency.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-array.h
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans-io.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
                   ` (3 preceding siblings ...)
  2010-02-20 12:47 ` pault at gcc dot gnu dot org
@ 2010-02-20 21:48 ` burnus at gcc dot gnu dot org
  2010-02-21 10:44 ` paul dot richard dot thomas at gmail dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-20 21:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2010-02-20 21:48 -------
Can this PR be closed? I think it is fixed now.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
                   ` (4 preceding siblings ...)
  2010-02-20 21:48 ` burnus at gcc dot gnu dot org
@ 2010-02-21 10:44 ` paul dot richard dot thomas at gmail dot com
  2010-02-22  5:44 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paul dot richard dot thomas at gmail dot com @ 2010-02-21 10:44 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 708 bytes --]



------- Comment #6 from paul dot richard dot thomas at gmail dot com  2010-02-21 10:43 -------
Subject: Re:  unneeded temporary (s=s+f(a))

Same as 41113 - I'll decide what to do tonight - see you on #gfortran?

Paul

On Sat, Feb 20, 2010 at 10:48 PM, burnus at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #5 from burnus at gcc dot gnu dot org  2010-02-20 21:48 -------
> Can this PR be closed? I think it is fixed now.
>
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072
>
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
>


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
                   ` (5 preceding siblings ...)
  2010-02-21 10:44 ` paul dot richard dot thomas at gmail dot com
@ 2010-02-22  5:44 ` pault at gcc dot gnu dot org
  2010-05-09 20:19 ` dfranke at gcc dot gnu dot org
  2010-05-19  4:28 ` pault at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-02-22  5:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2010-02-22 05:44 -------
Subject: Bug 43072

Author: pault
Date: Mon Feb 22 05:43:57 2010
New Revision: 156949

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=156949
Log:
2010-02-22  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43072
        * dependency.c (gfc_full_array_ref_p): Check for contiguous by
        checking the rest of the dimensions for elements.

2010-02-22  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/43072
        * gfortran.dg/internal_pack_6.f90: Number of 'packs' now zero.
        * gfortran.dg/internal_pack_9.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/internal_pack_9.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/dependency.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/internal_pack_6.f90


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
                   ` (6 preceding siblings ...)
  2010-02-22  5:44 ` pault at gcc dot gnu dot org
@ 2010-05-09 20:19 ` dfranke at gcc dot gnu dot org
  2010-05-19  4:28 ` pault at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2010-05-09 20:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from dfranke at gcc dot gnu dot org  2010-05-09 20:19 -------
(In reply to comment #6)
> Same as 41113 - I'll decide what to do tonight - see you on #gfortran?

PR41113 is closed as fixed - can this be closed as well?


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dfranke at gcc dot gnu dot
                   |                            |org
             Status|NEW                         |WAITING


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

* [Bug fortran/43072] unneeded temporary (s=s+f(a))
  2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
                   ` (7 preceding siblings ...)
  2010-05-09 20:19 ` dfranke at gcc dot gnu dot org
@ 2010-05-19  4:28 ` pault at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu dot org @ 2010-05-19  4:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2010-05-19 04:28 -------
Fixed.  Thanks, Joost!

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43072


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

end of thread, other threads:[~2010-05-19  4:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-15  7:37 [Bug fortran/43072] New: unneeded temporary (s=s+f(a)) jv244 at cam dot ac dot uk
2010-02-15  7:51 ` [Bug fortran/43072] " pault at gcc dot gnu dot org
2010-02-15  7:58 ` jv244 at cam dot ac dot uk
2010-02-16 15:47 ` pault at gcc dot gnu dot org
2010-02-20 12:47 ` pault at gcc dot gnu dot org
2010-02-20 21:48 ` burnus at gcc dot gnu dot org
2010-02-21 10:44 ` paul dot richard dot thomas at gmail dot com
2010-02-22  5:44 ` pault at gcc dot gnu dot org
2010-05-09 20:19 ` dfranke at gcc dot gnu dot org
2010-05-19  4:28 ` pault 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).