public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59845] New: loop optimization problem when profiling
@ 2014-01-16 18:12 arshamidi at gmail dot com
  2014-01-16 19:08 ` [Bug c++/59845] " arshamidi at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: arshamidi at gmail dot com @ 2014-01-16 18:12 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-15 10:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-16 18:12 [Bug c++/59845] New: loop optimization problem when profiling arshamidi at gmail dot com
2014-01-16 19:08 ` [Bug c++/59845] " arshamidi at gmail dot com
2014-01-16 19:18 ` pinskia at gcc dot gnu.org
2014-01-17  8:52 ` arshamidi at gmail dot com
2015-02-15 10:59 ` arshamidi at gmail dot com

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).