public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43829]  New: Scalarization of reductions
@ 2010-04-21 12:24 rguenth at gcc dot gnu dot org
  2010-04-21 12:52 ` [Bug fortran/43829] Scalarization of reductions with Fortran array expressions steven at gcc dot gnu dot org
                   ` (29 more replies)
  0 siblings, 30 replies; 54+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-04-21 12:24 UTC (permalink / raw)
  To: gcc-bugs

465.tonto in one of its hot loops does essentially what the following reduced
testcase does:

subroutine make_esss(esss,Ix,Iyz,e_x,ii_ivec)
  real(kind=kind(1.0d0)), dimension(:), intent(inout) :: esss
  real(kind=kind(1.0d0)), dimension(:,:), pointer :: Ix,Iyz
  integer(kind=kind(1)), dimension(:), pointer  :: e_x,ii_ivec

  esss(:) = esss(:) + sum(Ix(:,e_x) * Iyz(:,ii_ivec), 1)

end subroutine

this is scalarized by the frontend to

  atmp4 = e_x
  atmp6 = ii_ivec
  atmp8 = Ix(:,atmp4) * Iyz(:,atmp6)
  atmp11 = sum (atmp8, 1)
  ess = ess + atmp11

where the sum is not inline-expanded.

1) the temporaries for e_x and ii_ivec are not necessary
2) the sum can easily be inline-expanded as the shape of atmp8 is well-defined
3) we can avoid atmp8 by expanding sum(Ix(:,e_x), Iyz(:ii_ivec), 1) together
   like

                atmp11(z) = 0
                do z=1,size(Ix,1)
                  atmp11(z) = atmp11(z) + Ix(z,e_x(e)) * Iyz(z,ii_ivec(e))
                end do

   or even avoid atmp11 alltogether and expand to

              do e=1,size(esss,1)
                tem = 0
                do z=1,size(Ix,1)
                  tem = tem + Ix(z,e_x(e)) * Iyz(z,ii_ivec(e))
                end do
                esss(e) = esss(e) + tem
              end do

   given that esss does not have the target attribute and thus cannot
   be aliased by e_x or ii_ivec.


-- 
           Summary: Scalarization of reductions
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 54+ messages in thread
[parent not found: <bug-43829-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2012-03-04 19:14 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-21 12:24 [Bug fortran/43829] New: Scalarization of reductions rguenth at gcc dot gnu dot org
2010-04-21 12:52 ` [Bug fortran/43829] Scalarization of reductions with Fortran array expressions steven at gcc dot gnu dot org
2010-04-21 13:08 ` [Bug fortran/43829] Scalarization of reductions rguenth at gcc dot gnu dot org
2010-04-21 14:27 ` rguenth at gcc dot gnu dot org
2010-04-22  8:35 ` rguenth at gcc dot gnu dot org
2010-04-22 14:00 ` rguenth at gcc dot gnu dot org
2010-04-22 15:40 ` rguenth at gcc dot gnu dot org
2010-04-23 16:09 ` rguenth at gcc dot gnu dot org
2010-05-04 23:08 ` mikael at gcc dot gnu dot org
2010-05-05  5:08 ` pault at gcc dot gnu dot org
2010-05-05 15:44 ` rguenth at gcc dot gnu dot org
2010-05-22 19:36 ` mikael at gcc dot gnu dot org
2010-06-25  9:28 ` mikael at gcc dot gnu dot org
2010-06-25  9:34 ` mikael at gcc dot gnu dot org
2010-06-25  9:37 ` mikael at gcc dot gnu dot org
2010-06-25  9:42 ` mikael at gcc dot gnu dot org
2010-06-25  9:45 ` rguenther at suse dot de
2010-06-25 22:09 ` dominiq at lps dot ens dot fr
2010-06-26  9:06 ` mikael at gcc dot gnu dot org
2010-06-27 12:42 ` mikael at gcc dot gnu dot org
2010-06-27 12:50 ` mikael at gcc dot gnu dot org
2010-06-27 19:20 ` dominiq at lps dot ens dot fr
2010-06-27 19:45 ` burnus at gcc dot gnu dot org
2010-06-27 20:05 ` dominiq at lps dot ens dot fr
2010-06-27 21:30 ` dominiq at lps dot ens dot fr
2010-06-28  4:28 ` paul dot richard dot thomas at gmail dot com
2010-06-28  9:36 ` rguenth at gcc dot gnu dot org
2010-09-08 11:29 ` dominiq at lps dot ens dot fr
2010-09-08 17:21 ` mikael at gcc dot gnu dot org
2010-09-13  9:09 ` dominiq at lps dot ens dot fr
2010-09-13 17:10 ` mikael at gcc dot gnu dot org
     [not found] <bug-43829-4@http.gcc.gnu.org/bugzilla/>
2011-02-07 18:53 ` mikael at gcc dot gnu.org
2011-02-07 18:58 ` mikael at gcc dot gnu.org
2011-03-01 15:41 ` dominiq at lps dot ens.fr
2011-03-04 23:15 ` mikael at gcc dot gnu.org
2011-10-04 13:18 ` matz at gcc dot gnu.org
2011-10-04 16:05 ` paul.richard.thomas at gmail dot com
2011-10-04 21:57 ` mikael at gcc dot gnu.org
2011-10-05  6:41 ` paul.richard.thomas at gmail dot com
2011-10-05 14:11 ` burnus at gcc dot gnu.org
2011-10-05 18:12 ` mikael at gcc dot gnu.org
2011-10-08 16:28 ` mikael at gcc dot gnu.org
2011-10-08 16:31 ` mikael at gcc dot gnu.org
2011-10-08 17:58 ` mikael at gcc dot gnu.org
2011-10-09  9:48 ` paul.richard.thomas at gmail dot com
2011-10-09 16:02 ` dominiq at lps dot ens.fr
2011-10-09 16:45 ` mikael at gcc dot gnu.org
2011-10-10  9:06 ` rguenther at suse dot de
2011-11-04  0:31 ` mikael at gcc dot gnu.org
2011-11-04  0:46 ` mikael at gcc dot gnu.org
2011-11-04  1:08 ` mikael at gcc dot gnu.org
2011-11-04  1:11 ` mikael at gcc dot gnu.org
2011-11-26  6:51 ` mikael at gcc dot gnu.org
2012-03-04 19:14 ` mikael at gcc dot gnu.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).