Bug 36915 - Unneccessary array temporary for same_array_ptr = const * same_array_ptr
Summary: Unneccessary array temporary for same_array_ptr = const * same_array_ptr
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 enhancement
Target Milestone: 4.4.3
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: 36842 36854
  Show dependency treegraph
 
Reported: 2008-07-24 08:38 UTC by Tobias Burnus
Modified: 2010-05-09 20:25 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-07-28 10:38:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2008-07-24 08:38:43 UTC
Maybe this could be handled by the Middle End, once the array operations in the ME are implemented. This would save us from checking the alias information in the FE.

Regarding the "Middle-End Array Expressions", see:
http://www.gccsummit.org/2008/gcc-2008-proceedings.pdf, pp. 33-42.

 * * *

From: http://gcc.gnu.org/ml/fortran/2008-07/msg00166.html

PS The example from Daniel,

SUBROUTINE sub(I)
 REAL, PARAMETER :: PI = 3.1415
 REAL, DIMENSION(:), POINTER   :: I
 I = 2.0 * PI**2 * I
END SUBROUTINE

produces a temporary because the scalarizer makes no attempt to
resolve pointers, for obvious reasons.  We could add a check that the
only pointer on the rhs is the same as that on the lhs, with no
dependencies, and that there are no targets in the rhs expression.
Comment 1 Daniel Franke 2008-07-24 10:14:09 UTC
Tobias, thanks for opening the PR.
Comment 2 Richard Biener 2008-07-24 13:03:02 UTC
See also PR36842 which would benefit as well.
Comment 3 Tobias Burnus 2008-07-25 08:43:23 UTC
See also PR 36928 (interleaved assignment, where also an unneeded temporary is created).
Comment 4 Thomas Koenig 2008-07-28 10:38:58 UTC
Confirmed.
Comment 5 Daniel Franke 2010-05-09 20:25:10 UTC
This seemingly was fixed a while ago; -Warray-temporaries does not warn for 4.4.3, 4.5.1 nor current trunk. 

Relevant section of the dump is:
      while (1)
        {
          if (S.0 > D.1515) goto L.1;
          (*D.1516)[(S.0 + D.1520) * D.1523 + D.1517] = (*D.1512)[S.0 * D.1522 + D.1513] * 1.973804473876953125e+1;
          S.0 = S.0 + 1;
        }


Closing as fixed.