From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17298 invoked by alias); 8 Nov 2011 22:19:20 -0000 Received: (qmail 17290 invoked by uid 22791); 8 Nov 2011 22:19:20 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Nov 2011 22:19:06 +0000 From: "fb.programming at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug other/51041] New: g++ strange optimisation behaviour Date: Tue, 08 Nov 2011 22:21:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: other X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fb.programming at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg00836.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51041 Bug #: 51041 Summary: g++ strange optimisation behaviour Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: other AssignedTo: unassigned@gcc.gnu.org ReportedBy: fb.programming@gmail.com The attached code repeatedly executes a vector * vector product to test the performance of the system. Compiled with g++ -Wall -O2 file.cpp it results in a performance of about 1.7 Gflops on an Intel i5-750, ie the output is adding: 0.059 s, 1.695 GFlops, sum=0.000000 However, when adding another printf (remove the comment in front of the last printf) the performance deteriorates strongly (same compiler options): adding: 0.195 s, 0.512 GFlops, sum=0.000000 sum=0.000000 It seems the last printf confuses the compiler optimisation completely, although it shouldn't make a difference at all, as the same variable is already printed a few lines above. This is worrying as it seems the compiler fails to fully optimise the code under odd circumstances. I've used compiler version 4.6.2 as well as 4.4.1 which is the default compiler on the system. $ gcc-4.6.2 --version gcc-4.6.2 (GCC) 4.6.2 $ gcc --version gcc (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839] $ uname -a Linux localhost 2.6.31.14-0.8-desktop #1 SMP PREEMPT 2011-04-06 18:09:24 +0200 x86_64 x86_64 x86_64 GNU/Linux