public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guillaume dot melquiond at ens-lyon dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/16405] Non optimized code when using default copy constructor
Date: Mon, 19 Jul 2004 09:19:00 -0000	[thread overview]
Message-ID: <20040719091943.23824.qmail@sourceware.org> (raw)
In-Reply-To: <20040707115615.16405.guillaume.melquiond@ens-lyon.fr>


------- Additional Comments From guillaume dot melquiond at ens-lyon dot fr  2004-07-19 09:19 -------
As a follow-up, I also tested with g++ 3.4.1 and 3.5-20040717.

The problem still exists with 3.4.1. There are still one more temporary and one
more copy than with 3.3.4.

The situation is a bit better with 3.5 than it was with the previous tested
snapshot. It is almost as good as with 3.4.1. There are only two more
temporaries and one more copy than with 3.3.4.

So both gcc 3.4 and 3.5 produce one more copy than gcc 3.3. I timed the cost of
this extra copy on the code below (-O3 compilation as before). It incurs a ~25%
slowdown of the whole program on an Intel P4 processor.

-------------------------------------------------------
struct T {
  int a[500];
  T &operator+=(T const &v) { for(int i = 0; i < 500; ++i) a[i] += v.a[i];
return *this; }
  T operator+(T const &v) const { T t = *this; t += v; return t; }
};

T a, b, c;

int main() {
  for(int i = 0; i < 10000000; ++i) a = b + c;
  return 0;
}

-- 


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


  parent reply	other threads:[~2004-07-19  9:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-07 11:56 [Bug c++/16405] New: " guillaume dot melquiond at ens-lyon dot fr
2004-07-07 15:44 ` [Bug c++/16405] " pinskia at gcc dot gnu dot org
2004-07-19  9:19 ` guillaume dot melquiond at ens-lyon dot fr [this message]
2004-10-07 11:51 ` [Bug c++/16405] [3.4/4.0 Regression] Temporary aggregate copy not elided giovannibajo at libero dot it
2004-11-01  0:45 ` [Bug tree-optimization/16405] " mmitchel at gcc dot gnu dot org
2004-12-23  4:45 ` [Bug c++/16405] " mmitchel at gcc dot gnu dot org
2004-12-23  8:17 ` cvs-commit at gcc dot gnu dot org
2004-12-23  8:18 ` [Bug c++/16405] [3.4 " mmitchel at gcc dot gnu dot org
2004-12-23 16:27 ` cvs-commit at gcc dot gnu dot org
2005-02-13 18:38 ` cvs-commit at gcc dot gnu dot org
2005-05-19 17:40 ` mmitchel at gcc dot gnu dot 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=20040719091943.23824.qmail@sourceware.org \
    --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).