On Tuesday 19 December 2006 23:39, Denis Vlasenko wrote:
> There are a lot of 100.00% safe optimizations which gcc
> can do. Value range propagation for bitwise operations, for one
Or this, absolutely typical C code. i386 arch can compare
16 bits at a time here (luckily, no alighment worries on this arch):
# cat tt.c
int f(char *p)
{
if (p[0] == 1 && p[1] == 2) return 1;
return 0;
}
# gcc -O2 -S -fomit-frame-pointer tt.c
# cat tt.s
.file "tt.c"
.text
.p2align 2,,3
.globl f
.type f, @function
f:
movl 4(%esp), %eax
cmpb $1, (%eax)
je .L2
xorl %eax, %eax
ret
.p2align 2,,3
.L2:
cmpb $2, 1(%eax)
sete %al
movzbl %al, %eax
ret
.size f, .-f
.ident "GCC: (GNU) 4.2.0 20061128 (prerelease)"
.section .note.GNU-stack,"",@progbits