public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/38751]  New: Odd performance regression with -Os
@ 2009-01-07 10:04 aph at gcc dot gnu dot org
  2009-01-07 10:11 ` [Bug middle-end/38751] [4.2/4.3/4.4] odd " ebotcazou at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: aph at gcc dot gnu dot org @ 2009-01-07 10:04 UTC (permalink / raw)
  To: gcc-bugs

Here's a strange case of poor code generation with -Os.

unsigned short foo2 (unsigned char on_off, unsigned short *puls)
{
  return puls[on_off-1];
}

With -O2, it's fine:

        movzbl  %dil, %edi
        movzwl  -2(%rsi,%rdi,2), %eax
        ret

With -Os it's really weird:

        movzbl  %dil, %eax
        movl    $1, %edi
        subq    %rax, %rdi
        imulq   $-2, %rdi, %rdi
        movw    (%rdi,%rsi), %ax
        ret

The problem here seems to be that the FE (or the GIMPLE generation)
transforms

        addr + ((on_off-1)*2)

into

        addr + ((1-on_off)*-2)

and nothing in -Os has the wit to recover.  This badly affects targets
with no hardware multiplier, which end up calling libgcc to do the
multiply.

http://gcc.gnu.org/ml/gcc/2008-12/msg00329.html


-- 
           Summary: Odd performance regression with -Os
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aph at gcc dot gnu dot org


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


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

end of thread, other threads:[~2009-06-25 12:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-07 10:04 [Bug middle-end/38751] New: Odd performance regression with -Os aph at gcc dot gnu dot org
2009-01-07 10:11 ` [Bug middle-end/38751] [4.2/4.3/4.4] odd " ebotcazou at gcc dot gnu dot org
2009-01-07 10:53 ` [Bug middle-end/38751] [4.2/4.3/4.4 regression] " rguenth at gcc dot gnu dot org
2009-01-15  1:13 ` pinskia at gcc dot gnu dot org
2009-01-15 13:57 ` [Bug middle-end/38751] [4.2/4.3 " jakub at gcc dot gnu dot org
2009-01-15 16:16 ` rguenth at gcc dot gnu dot org
2009-03-31 21:07 ` [Bug middle-end/38751] [4.3 " jsm28 at gcc dot gnu dot org
2009-04-22 15:20 ` rguenth at gcc dot gnu dot org
2009-06-25 12:39 ` [Bug middle-end/38751] [4.3 Regression] " rguenth at gcc dot gnu dot org
2009-06-25 12:39 ` rguenth at gcc dot gnu dot 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).