public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48655] New: False positive with -Warray-temporaries and a=transpose(a)
@ 2011-04-17 20:16 tkoenig at gcc dot gnu.org
  2013-01-07 22:56 ` [Bug fortran/48655] " dominiq at lps dot ens.fr
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-04-17 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: False positive with -Warray-temporaries and
                    a=transpose(a)
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tkoenig@gcc.gnu.org


Well, the front end generates the temporary, but the middle end removes it
again.

ig25@linux-fd1f:~/Dokumente/ig25/Transpose> cat foo.f90               
subroutine foo(a,x)                               
  real, dimension(3,3), intent(out) :: a                                   
  real, intent(in) :: x

  a(1,1) = 1.0
  a(2,1) = 1.3 + x
  a(3,1) = 1.0    
  a(1,2) = 1.43   
  a(2,2) = 2*x    
  a(3,2) = x**2   
  a(1,3) = -x     
  a(2,3) = -x**2  
  a(3,3) = 2.1    
  a = transpose(a)
end subroutine foo

ig25@linux-fd1f:~/Dokumente/ig25/Transpose> gfortran -O3 -c
-fdump-tree-optimized -fdump-tree-original -Warray-temporaries foo.f90          
foo.f90:14.6:                                                                   

  a = transpose(a)
      1
Warnung: Creating array temporary at (1)
ig25@linux-fd1f:~/Dokumente/ig25/Transpose> cat foo.f90.142t.optimized

;; Function foo (foo_)

foo (real(kind=4)[9] * restrict a, real(kind=4) & restrict x)
{
  real(kind=4) D.1549;
  real(kind=4) D.1586;
  real(kind=4) D.1585;
  real(kind=4) D.1584;
  real(kind=4) D.1583;
  real(kind=4) D.1582;

<bb 2>:
  *a_5(D)[0] = 1.0e+0;
  D.1582_7 = *x_6(D);
  D.1583_8 = D.1582_7 + 1.2999999523162841796875e+0;
  D.1584_10 = D.1582_7 * 2.0e+0;
  *a_5(D)[4] = D.1584_10;
  D.1549_12 = D.1582_7 * D.1582_7;
  D.1585_14 = -D.1582_7;
  D.1586_17 = -D.1549_12;
  *a_5(D)[8] = 2.099999904632568359375e+0;
  *a_5(D)[1] = 1.42999994754791259765625e+0;
  *a_5(D)[2] = D.1585_14;
  *a_5(D)[3] = D.1583_8;
  *a_5(D)[5] = D.1586_17;
  *a_5(D)[6] = 1.0e+0;
  *a_5(D)[7] = D.1549_12;
  return;

}


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

* [Bug fortran/48655] False positive with -Warray-temporaries and a=transpose(a)
  2011-04-17 20:16 [Bug fortran/48655] New: False positive with -Warray-temporaries and a=transpose(a) tkoenig at gcc dot gnu.org
@ 2013-01-07 22:56 ` dominiq at lps dot ens.fr
  2014-12-07 14:34 ` dominiq at lps dot ens.fr
  2020-04-14 18:08 ` [Bug fortran/48655] "False positive" with -Warray-temporaries or missing warning with -fcheck=array-temps nickpapior at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-01-07 22:56 UTC (permalink / raw)
  To: gcc-bugs


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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-07
     Ever Confirmed|0                           |1

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-01-07 22:56:20 UTC ---
I think this has to be fixed at the documentation level (unless the optimizer
is able to report that a temporary has been removed). Presently the manual
says:

> -Warray-temporaries
> Warn about array temporaries generated by the compiler. 
> The information generated by this warning is sometimes useful 
> in optimization, in order to avoid such temporaries. 

What about replacing the first sentence with "Warn about array temporaries
generated by the front-end" (if front-end is found too geek speak, one could
use "by the early stage of the compiler" or whatever is deemed suitable). Then
one could add a sentence of the kind "Note that some optimizing stage can
silently remove the temporary if it can prove it is not necessary." (again
translation from Frenglish to plain English welcomed).


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

* [Bug fortran/48655] False positive with -Warray-temporaries and a=transpose(a)
  2011-04-17 20:16 [Bug fortran/48655] New: False positive with -Warray-temporaries and a=transpose(a) tkoenig at gcc dot gnu.org
  2013-01-07 22:56 ` [Bug fortran/48655] " dominiq at lps dot ens.fr
@ 2014-12-07 14:34 ` dominiq at lps dot ens.fr
  2020-04-14 18:08 ` [Bug fortran/48655] "False positive" with -Warray-temporaries or missing warning with -fcheck=array-temps nickpapior at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-12-07 14:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48655

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
See also pr63689.


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

* [Bug fortran/48655] "False positive" with -Warray-temporaries or missing warning with -fcheck=array-temps
  2011-04-17 20:16 [Bug fortran/48655] New: False positive with -Warray-temporaries and a=transpose(a) tkoenig at gcc dot gnu.org
  2013-01-07 22:56 ` [Bug fortran/48655] " dominiq at lps dot ens.fr
  2014-12-07 14:34 ` dominiq at lps dot ens.fr
@ 2020-04-14 18:08 ` nickpapior at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: nickpapior at gmail dot com @ 2020-04-14 18:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48655

Nick <nickpapior at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickpapior at gmail dot com

--- Comment #9 from Nick <nickpapior at gmail dot com> ---
I really think this needs fixing.

A user (me) is unaware of the implications and differences between
-Warray-temporaries and -fcheck=array-temps.

E.g. from this discussion it seems that

-Warray-temporaries only pin-points where there _could_ be problems of creating
temporaries.

-fcheck=array-temps will reveal true temporary copies created.



However, I have found that our code (+100.000 LOC) can greatly benefit closing
-Warray-temporaries even if -fcheck=array-temps did not show any temporaries
created. Why is this?

So some follow up questions to clarify the flags:

1) Is there any compiled code difference in places where -Warray-temporaries
show up, e.g. can we assume that IFF -Warray-temporaries gives a warning it is
equivalent to the compiler inserting something like:

if (is_contiguous(A) ) then
call with no temp
else
temp = A(...)
call with_temp
deallocate(temp)
end if

?
And if not, then there is nothing to worry about?

2) Can we be sure that -fcheck=array-temps actually shows all true positives
related to temporary array creation?


What I would really like is the following changes to the documentation:

-Warray-temporaries:
Warn about possible array temporaries generated by the compiler. The
information generated by this warning is sometimes useful in optimization, in
order to avoid such temporaries. If this warning is issued it is equivalent to
extra code checking for contiguous arrays before determining whether a
temporary is created. To assert a temporary array was created, use
-fcheck=array-temps. 

If extra code is not generated when a warning is issued then the 2nd last line
should be omitted.



Additionally the Warning message should be clarified, currently it looks like:

Warning: Creating array temporary at (1) [-Warray-temporaries]

However, I think it should look like this:

Warning: Creating array temporary at (1) if non-contiguous
[-Warray-temporaries]

Thanks!

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

end of thread, other threads:[~2020-04-14 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-17 20:16 [Bug fortran/48655] New: False positive with -Warray-temporaries and a=transpose(a) tkoenig at gcc dot gnu.org
2013-01-07 22:56 ` [Bug fortran/48655] " dominiq at lps dot ens.fr
2014-12-07 14:34 ` dominiq at lps dot ens.fr
2020-04-14 18:08 ` [Bug fortran/48655] "False positive" with -Warray-temporaries or missing warning with -fcheck=array-temps nickpapior at gmail dot com

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