This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Missed optimization


We should produce the same code for these two functions, but we don't.

extern const char table[];

int x(int c)
{
  return (table[c] & 0x01) || (table[c] & 0x10);
}

int y(int c)
{
  return !!(table[c] & 0x11);
}

-> 

x:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %eax
        xorl    %edx, %edx
        movzbl  table(%eax), %eax
        testl   $1, %eax
        je      .L5
.L4:
        movl    $1, %edx
.L3:
        popl    %ebp
        movl    %edx, %eax
        ret
        .p2align 4,,7
.L5:
        andl    $16, %eax
        jne     .L4
        jmp     .L3


y:
        pushl   %ebp
        movl    %esp, %ebp
        movl    8(%ebp), %edx
        popl    %ebp
        xorl    %eax, %eax
        testb   $17, table(%edx) 
        setne   %al
        ret

(i386-pc-linux-gnu, 2.97 20001126 (CVS as of last night)).

zw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]