From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23854 invoked by alias); 19 Jul 2004 09:19:45 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 23825 invoked by uid 48); 19 Jul 2004 09:19:43 -0000 Date: Mon, 19 Jul 2004 09:19:00 -0000 Message-ID: <20040719091943.23824.qmail@sourceware.org> From: "guillaume dot melquiond at ens-lyon dot fr" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040707115615.16405.guillaume.melquiond@ens-lyon.fr> References: <20040707115615.16405.guillaume.melquiond@ens-lyon.fr> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/16405] Non optimized code when using default copy constructor X-Bugzilla-Reason: CC X-SW-Source: 2004-07/txt/msg02280.txt.bz2 List-Id: ------- 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