Missed optimization
Zack Weinberg
zackw@stanford.edu
Mon Nov 27 09:48:00 GMT 2000
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
More information about the Gcc-bugs
mailing list