From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28158 invoked by alias); 16 Jan 2014 18:12:56 -0000 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 Received: (qmail 28126 invoked by uid 48); 16 Jan 2014 18:12:49 -0000 From: "arshamidi at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/59845] New: loop optimization problem when profiling Date: Thu, 16 Jan 2014 18:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: arshamidi 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-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg01736.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59845 Bug ID: 59845 Summary: loop optimization problem when profiling Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: arshamidi at gmail dot com I'm using g++ with GCC 4.8.1; when I use fprofile-generate too optimize my code, it actually slows down the process time: (constant folding problem within loop?) int main(){ int n; int i; //int n2; printf("Enter a number: "); scanf("%d", &n); //n2 = n/2; printf("divisors are:\n\n"); for (i=1; i <= /*n2*/ n/2; i++) if (n%i == 0) printf("\n%d", i); printf("\n\n end.\n"); return 0; } Here I must use the constant 'n2' (commented out) too actually get the desired speed -in combination with -fprofile-generate. I'm using the following switches: -Ofast;-fomit-frame-pointer;-march=core2; -mfpmath=sse; -fprofile-generate; -Wall no problem without -fprofile-generate and -fprofile-use