public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/56937] Unnecessarily temporary with array-vector assignments
Date: Fri, 12 Apr 2013 20:56:00 -0000	[thread overview]
Message-ID: <bug-56937-4-YUmGFTDXbz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56937-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-04-12 20:56:36 UTC ---
Is the following code valid?

integer :: i, idx(4), r(4), p(4)
p = [1,2,3,4]
idx = [2,2,2,2]
r = 0
r(idx) = p
print *, sum(r)
r = 0
do i = 1, 4
  r(idx(i)) = p(i)
end do
print *, sum(r)
r = 0
do i = 4, 1, -1
  r(idx(i)) = p(i)
end do
print *, sum(r)

end

The output is

           4
           4
           1

i.e., the value of r(2) depends on the way the assignment is scalarized: my
rule of thumb for missing temporary and/or invalid code.


  reply	other threads:[~2013-04-12 20:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-12 18:12 [Bug fortran/56937] New: " burnus at gcc dot gnu.org
2013-04-12 20:56 ` dominiq at lps dot ens.fr [this message]
2013-04-12 21:28 ` [Bug fortran/56937] " burnus at gcc dot gnu.org
2013-04-13 10:15 ` mikael at gcc dot gnu.org
2013-04-13 10:26 ` mikael at gcc dot gnu.org
2013-04-13 10:32 ` mikael at gcc dot gnu.org
2013-04-29 22:26 ` dominiq at lps dot ens.fr
2013-04-30 11:58 ` tkoenig at gcc dot gnu.org
2013-04-30 12:15 ` dominiq at lps dot ens.fr
2013-04-30 12:35 ` burnus at gcc dot gnu.org
2013-07-21 13:47 ` tkoenig at gcc dot gnu.org
2013-07-21 13:50 ` tkoenig at gcc dot gnu.org
2013-08-09  9:20 ` tkoenig at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-56937-4-YUmGFTDXbz@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).