The following code: void func(); void test(char *signature) { char ch = signature[0]; if (ch == 15 || ch == 3) { if (ch == 15) func(); } } is compiled in suboptimal way by gcc 4.4. Check for ch==3 can be completely eliminated since func is only called if ch==15. gcc 4.3 is able to properly infer this and eliminate the unneeded check, but gcc 4.4 fails to do this.
Althouth, found originally on ARM, this bug also reproduces on x86 as well. gcc 4.3.1 (with -m32 -O2): test: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movzbl (%eax), %eax cmpb $15, %al // %al compared only with 15 jne .L8 popl %ebp jmp func .L8: popl %ebp ret gcc 4.4.0: test: pushl %ebp movl %esp, %ebp subl $8, %esp movl 8(%ebp), %eax movzbl (%eax), %eax cmpb $15, %al sete %dl cmpb $3, %al // compiler was not able to optimize ch==3 je .L4 testb %dl, %dl jne .L8 .L4: leave ret .p2align 4,,7 .p2align 3 .L8: leave .p2align 4,,8 .p2align 3 jmp func Bisection shows that it was introduced by http://gcc.gnu.org/viewcvs?view=rev&revision=140288 -- Summary: [4.4 regression] missing DCE Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alexvod at google dot com GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86-unknown-linux-gnu, arm-eabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39874