public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/49651] [C++0x] nested lambdas and -O3 produced incorrect integer variable increments
Date: Thu, 14 Jul 2011 12:27:00 -0000	[thread overview]
Message-ID: <bug-49651-4-hyyE9lbA3p@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49651-4@http.gcc.gnu.org/bugzilla/>

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-14 12:26:08 UTC ---
In the optimized dump I can see

<bb 4>:
...
  run.__v7 = &v7;
  run.__a = &a;
...

<bb 6>:
  # ivtmp.207_17 = PHI <ivtmp.207_68(10), ivtmp.207_69(5)>
  D.47092_58 = a;
  D.47093_59 = D.47092_58 + 1;
  a = D.47093_59;
  f (D.47092_58);

<bb 7>:
  D.47084_60 = MEM[(int * const &)&ve + 8];
  D.47090._M_current = D.47084_60;
  D.47083_61 = MEM[(int * const &)&ve];
  D.47089._M_current = D.47083_61;
  D.47091 = std::for_each<__gnu_cxx::__normal_iterator<int*, std::vector<int>
>, main(int, char**)::<lambda(int&)> > (D.47089, D.47090, run);

<bb 8>:
  D.47093_63 = D.47092_58 + 2;
  a = D.47093_63;
  f (D.47093_59);

<bb 9>:
  D.47082_64 = MEM[(int * const &)&ve + 8];
  D.47086._M_current = D.47082_64;
  D.47081_65 = MEM[(int * const &)&ve];
  D.47085._M_current = D.47081_65;
  D.47087 = std::for_each<__gnu_cxx::__normal_iterator<int*, std::vector<int>
>, main(int, char**)::<lambda(int&)> > (D.47085, D.47086, run);

<bb 10>:
  ivtmp.207_68 = ivtmp.207_17 + 4;
  __first$_M_current_66 = (int *) ivtmp.207_68;
  if (__last_27 != __first$_M_current_66)
    goto <bb 6>;
  else
...

so we do CSE a over the std::for_each invocation which gets run as argument.
That's wrong of course.  Alias-info tells us even that a is clobbered by
that call:

  # USE = nonlocal null { aD.40068 viD.40071 D.40875 veD.40876 D.40877
v7D.40878 }
  # CLB = nonlocal null { aD.40068 viD.40071 D.40875 veD.40876 D.40877
v7D.40878 }
  D.47091 = std::for_each<__gnu_cxx::__normal_iterator<int*, std::vector<int>
>, main(int, char**)::<lambda(int&)> > (D.47089, D.47090, runD.40880);

but it doesn't do so at the time when the first FRE is run:

  # USE = nonlocal null { viD.40071 D.40875 veD.40876 D.40877 v7D.40878 }
  # CLB = nonlocal null { viD.40071 D.40875 veD.40876 D.40877 v7D.40878 }
  D.47091 = std::for_each<__gnu_cxx::__normal_iterator<int*, std::vector<int>
>, main(int, char**)::<lambda(int&)> > (D.47089, D.47090,
*__f$__runD.47077_57);

the setup there is still not very optimized though.


  parent reply	other threads:[~2011-07-14 12:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05 20:15 [Bug c++/49651] New: " pedro.larroy at gmail dot com
2011-07-05 20:30 ` [Bug c++/49651] " pedro.larroy at gmail dot com
2011-07-05 21:54 ` redi at gcc dot gnu.org
2011-07-05 22:24 ` pedro.larroy at gmail dot com
2011-07-05 23:54 ` redi at gcc dot gnu.org
2011-07-12 14:39 ` [Bug tree-optimization/49651] " jason at gcc dot gnu.org
2011-07-12 15:21 ` rguenth at gcc dot gnu.org
2011-07-13 12:32 ` rguenth at gcc dot gnu.org
2011-07-14 12:27 ` rguenth at gcc dot gnu.org [this message]
2011-07-14 12:37 ` rguenth at gcc dot gnu.org
2011-07-14 13:02 ` [Bug tree-optimization/49651] [4.4/4.5/4.6/4.7 Regression] " rguenth at gcc dot gnu.org
2011-07-14 14:54 ` rguenth at gcc dot gnu.org
2011-07-14 14:57 ` rguenth at gcc dot gnu.org
2011-07-14 15:01 ` [Bug tree-optimization/49651] [4.4/4.5 " rguenth at gcc dot gnu.org
2011-08-01 14:09 ` rguenth at gcc dot gnu.org
2011-08-01 16:00 ` pedro.larroy at gmail dot com
2012-01-04  9:48 ` rguenth at gcc dot gnu.org
2012-01-04  9:50 ` rguenth at gcc dot gnu.org
2012-01-04 11:55 ` rguenth at gcc dot gnu.org
2012-01-04 11:56 ` [Bug tree-optimization/49651] [4.4 " rguenth at gcc dot gnu.org
2012-03-13 17:00 ` jakub 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-49651-4-hyyE9lbA3p@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).