public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/23100] New: poor code generation for i686
@ 2005-07-27 19:13 dann at godzilla dot ics dot uci dot edu
  2005-07-27 19:21 ` [Bug rtl-optimization/23100] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2005-07-27 19:13 UTC (permalink / raw)
  To: gcc-bugs

Compiling the code below (extracted from xterm-202) with
 -fno-inline -O2 -march=i686

typedef unsigned long Atom;

static int
CutBuffer(unsigned code) 
{
    int cutbuffer;
    switch (code) {
    case ((Atom) 9):
 cutbuffer = 0;
 break;
    case ((Atom) 10):
 cutbuffer = 1;
 break;
    case ((Atom) 11):
 cutbuffer = 2;
 break;
    case ((Atom) 12):
 cutbuffer = 3;
 break;
    case ((Atom) 13):
 cutbuffer = 4;
 break;
    case ((Atom) 14):
 cutbuffer = 5;
 break;
    case ((Atom) 15):
 cutbuffer = 6;
 break;
    case ((Atom) 16):
 cutbuffer = 7;
 break;
    default:
 cutbuffer = -1;
 break;
    }
    return cutbuffer;
}

int foo (unsigned code)
{
  return CutBuffer (code);
}

generates: 

CutBuffer:
        subl    $9, %eax
        movl    $-1, %edx
        pushl   %ebp
        cmpl    $7, %eax
        movl    %esp, %ebp
        ja      .L12
        jmp     *.L11(,%eax,4)
        .section        .rodata
        .align 4
        .align 4
.L11:
        .long   .L3
        .long   .L4
        .long   .L5
        .long   .L6
        .long   .L7
        .long   .L8
        .long   .L9
        .long   .L10
        .text
.L9:
        movl    $6, %edx
        .p2align 4,,15
.L12:
        popl    %ebp
        movl    %edx, %eax
        ret
.L3:
        popl    %ebp
        xorl    %edx, %edx
        movl    %edx, %eax
        .p2align 4,,2
        ret
.L10:
        popl    %ebp
        movl    $7, %edx
        movl    %edx, %eax
        ret
.L8:
        popl    %ebp
        movl    $5, %edx
        movl    %edx, %eax
        ret
.L7:
        popl    %ebp
        movl    $4, %edx
        movl    %edx, %eax
        ret
.L6:
        popl    %ebp
        movl    $3, %edx
        movl    %edx, %eax
        ret
[snip]

Note the sequences: movl NUMBER, %edx 
                    movl %edx, %eax

instead of using only one instruction for the same thing: movl NUMBER, %eax

-- 
           Summary: poor code generation for i686
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
@ 2005-07-27 19:21 ` pinskia at gcc dot gnu dot org
  2005-07-27 21:18 ` dann at godzilla dot ics dot uci dot edu
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-27 19:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-27 19:20 -------
This is the same issue as PR 16796 really, see comment #3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization, ra


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
  2005-07-27 19:21 ` [Bug rtl-optimization/23100] " pinskia at gcc dot gnu dot org
@ 2005-07-27 21:18 ` dann at godzilla dot ics dot uci dot edu
  2005-07-27 22:22 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2005-07-27 21:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2005-07-27 21:06 -------
The problem does not happen for i386: (ie using -fno-inline -O2 -march=i386)

CutBuffer:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $9, %eax
        cmpl    $7, %eax
        ja      .L2
        jmp     *.L11(,%eax,4)
        .section        .rodata
        .align 4
        .align 4
.L11:
        .long   .L3
        .long   .L4
        .long   .L5
        .long   .L6
        .long   .L7
        .long   .L8
        .long   .L9
        .long   .L10
        .text
        .p2align 2,,3
.L2:
        movl    $-1, %eax
        leave
        ret
.L3:
        xorl    %eax, %eax
        leave
        ret
.L10:
        movl    $7, %eax
        leave
        ret
.L9:
        movl    $6, %eax
        leave
        ret
.L8:
        movl    $5, %eax
        leave
        ret
.L7:
        movl    $4, %eax
        leave
        ret
.L6:
        movl    $3, %eax
        leave
        ret
[snip]

-- 


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
  2005-07-27 19:21 ` [Bug rtl-optimization/23100] " pinskia at gcc dot gnu dot org
  2005-07-27 21:18 ` dann at godzilla dot ics dot uci dot edu
@ 2005-07-27 22:22 ` pinskia at gcc dot gnu dot org
  2005-07-27 22:37 ` dann at godzilla dot ics dot uci dot edu
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-27 22:22 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-27 22:22 -------
Actually am I missing something, I get:
.L8:
        popl    %ebp
        movl    $5, %eax
        .p2align 4,,4
        ret



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|                            |i686-pc-linux-gnu


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
                   ` (2 preceding siblings ...)
  2005-07-27 22:22 ` pinskia at gcc dot gnu dot org
@ 2005-07-27 22:37 ` dann at godzilla dot ics dot uci dot edu
  2005-07-30 15:40 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2005-07-27 22:37 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2005-07-27 22:33 -------
(In reply to comment #3)
> Actually am I missing something, I get:
> .L8:
>         popl    %ebp
>         movl    $5, %eax
>         .p2align 4,,4
>         ret
Is that with -O2 -fno-inline -march=i686 ? 
I am using: 
"GCC: (GNU) 4.1.0 20050727 (experimental)"

-- 


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
                   ` (3 preceding siblings ...)
  2005-07-27 22:37 ` dann at godzilla dot ics dot uci dot edu
@ 2005-07-30 15:40 ` pinskia at gcc dot gnu dot org
  2005-07-30 15:43 ` pinskia at gcc dot gnu dot org
  2005-08-01 18:36 ` dann at godzilla dot ics dot uci dot edu
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-30 15:40 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-30 15:39 -------
Yes it is the same issue as PR 16796.

To reproduce this before 3.4.0, you have to add __attribute__((regparam(1))).  Though the code is worse 
than before 3.3.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |16796
              nThis|                            |
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.4.0 4.0.0 4.1.0
   Last reconfirmed|0000-00-00 00:00:00         |2005-07-30 15:39:09
               date|                            |


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
                   ` (4 preceding siblings ...)
  2005-07-30 15:40 ` pinskia at gcc dot gnu dot org
@ 2005-07-30 15:43 ` pinskia at gcc dot gnu dot org
  2005-08-01 18:36 ` dann at godzilla dot ics dot uci dot edu
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-30 15:43 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


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

* [Bug rtl-optimization/23100] poor code generation for i686
  2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
                   ` (5 preceding siblings ...)
  2005-07-30 15:43 ` pinskia at gcc dot gnu dot org
@ 2005-08-01 18:36 ` dann at godzilla dot ics dot uci dot edu
  6 siblings, 0 replies; 8+ messages in thread
From: dann at godzilla dot ics dot uci dot edu @ 2005-08-01 18:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2005-08-01 18:36 -------
Could another pass of "flow" (or some other pass that can clean-up the extra
moves) be scheduled to run after reorder-blocks? 
reorder-blocks is the pass that inserts the function epilogue in each switch case...

-- 


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


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

end of thread, other threads:[~2005-08-01 18:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-27 19:13 [Bug rtl-optimization/23100] New: poor code generation for i686 dann at godzilla dot ics dot uci dot edu
2005-07-27 19:21 ` [Bug rtl-optimization/23100] " pinskia at gcc dot gnu dot org
2005-07-27 21:18 ` dann at godzilla dot ics dot uci dot edu
2005-07-27 22:22 ` pinskia at gcc dot gnu dot org
2005-07-27 22:37 ` dann at godzilla dot ics dot uci dot edu
2005-07-30 15:40 ` pinskia at gcc dot gnu dot org
2005-07-30 15:43 ` pinskia at gcc dot gnu dot org
2005-08-01 18:36 ` dann at godzilla dot ics dot uci dot edu

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