public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/41741]  New: -Os generates bigger code than -O2 for simple loops
@ 2009-10-18 13:49 segher at kernel dot crashing dot org
  2009-10-18 13:53 ` [Bug middle-end/41741] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 3+ messages in thread
From: segher at kernel dot crashing dot org @ 2009-10-18 13:49 UTC (permalink / raw)
  To: gcc-bugs

Take the following example:

void *memset(void *b, int c, unsigned long len)
{
        unsigned long i;

        for (i = 0; i < len; i++)
                ((unsigned char *)b)[i] = c;

        return b;
}

-O2 generates:

memset:
        cmpwi 0,5,0
        beqlr 0
        mtctr 5
        rlwinm 4,4,0,0xff
        li 9,0
        .p2align 4,,15
.L3:
        stbx 4,3,9
        addi 9,9,1
        bdnz .L3
        blr

but -Os does:

memset:
        cmpwi 7,5,0
        li 9,0
        addi 5,5,1
        bne+ 7,.L2
        li 5,1
        b .L2
.L3:
        stbx 4,3,9
        addi 9,9,1
.L2:
        addic. 5,5,-1
        bne 0,.L3
        blr

which is much worse and bigger.


-- 
           Summary: -Os generates bigger code than -O2 for simple loops
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: segher at kernel dot crashing dot org
GCC target triplet: powerpc-linux


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


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

* [Bug middle-end/41741] -Os generates bigger code than -O2 for simple loops
  2009-10-18 13:49 [Bug middle-end/41741] New: -Os generates bigger code than -O2 for simple loops segher at kernel dot crashing dot org
@ 2009-10-18 13:53 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-10-18 13:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-10-18 13:53 -------
I think that's the usual loop-header copying trade-off.  If you do it you
possibly increase code size, if you don't, you lose optimization - especially
on induction variables.


-- 


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


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

* [Bug middle-end/41741] -Os generates bigger code than -O2 for simple loops
       [not found] <bug-41741-4@http.gcc.gnu.org/bugzilla/>
@ 2012-08-16 10:35 ` segher at gcc dot gnu.org
  0 siblings, 0 replies; 3+ messages in thread
From: segher at gcc dot gnu.org @ 2012-08-16 10:35 UTC (permalink / raw)
  To: gcc-bugs

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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |segher at gcc dot gnu.org
         Resolution|                            |FIXED

--- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> 2012-08-16 10:34:42 UTC ---
Current mainline does:

memset:
        addi 5,5,1
        li 9,0
        mtctr 5
        b .L2
.L3:
        stbx 4,3,9
        addi 9,9,1
.L2:
        bdnz .L3
        blr

So closing as fixed.


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

end of thread, other threads:[~2012-08-16 10:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-18 13:49 [Bug middle-end/41741] New: -Os generates bigger code than -O2 for simple loops segher at kernel dot crashing dot org
2009-10-18 13:53 ` [Bug middle-end/41741] " rguenth at gcc dot gnu dot org
     [not found] <bug-41741-4@http.gcc.gnu.org/bugzilla/>
2012-08-16 10:35 ` segher at gcc dot gnu.org

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