------- Comment #7 from uros at kss-loka dot si 2006-09-05 13:43 ------- Hm, proposed patch now generates worse code for following test:
extern int fnc1(void); extern int fnc2(void); int test(int x) { if (x & 0x02) return fnc1(); else if (x & 0x01) return fnc2(); else return 0; } It generates: test: movl 4(%esp), %edx movl %edx, %eax andl $2, %eax jne .L10 andl $1, %edx jne .L11 xorl %eax, %eax ret .p2align 4,,7 .L11: .p2align 4,,8 jmp fnc2 .p2align 4,,7 .L10: .p2align 4,,7 jmp fnc1 due to marking %eax live in first comparison, "and" is used instead of "test", and a regmove is emitted before comparison. Ideally gcc should generate: test: movl 4(%esp), %eax testl $2, %eax jne .L6 andl $1, %eax jne .L7 xorl %eax, %eax ret .p2align 2,,3 .L7: jmp fnc2 .p2align 2,,3 .L6: jmp fnc1 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28946