This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Missed optimization
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Missed optimization
- From: "Zack Weinberg" <zackw at stanford dot edu>
- Date: Mon, 27 Nov 2000 09:48:26 -0800
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