Re: Need advice: x86 redudant compare to zero

2005-10-13 Thread Richard Henderson
On Thu, Oct 13, 2005 at 08:10:27PM -0400, Andrew Pinski wrote: > PowerPC describes the pattern were we don't need the result of n after a > compare as: Except that we *do* need the result of N after the compare in this case. r~

Re: Need advice: x86 redudant compare to zero

2005-10-13 Thread Richard Kenner
My question is: where and how would you suggest we do this optimization. With peephole2? Or in combine? In i386.md, I see pattern *subsi_2 looks like what I'd like to combine these two insn into: (define_insn "*subsi_2" [(set (reg FLAGS_REG) (compare

Re: Need advice: x86 redudant compare to zero

2005-10-13 Thread Dale Johannesen
My question is: where and how would you suggest we do this optimization. With peephole2? Or in combine? In i386.md, I see pattern *subsi_2 looks like what I'd like to combine these two insn into: (define_insn "*subsi_2" [(set (reg FLAGS_REG) (compare (minus:SI (match_operand:SI 1

Re: Need advice: x86 redudant compare to zero

2005-10-13 Thread Andrew Pinski
On Oct 13, 2005, at 7:41 PM, Evan Cheng wrote: Hi, Here is a bits of code from bzip2: #define mswap(zz1, zz2) { int zztmp = zz1; zz1 = zz2; zz2 = zztmp; } void foo(int unLo, int unHi, int ltLo, int *ptr, char *block, int med, int d, int n) { while (1) { if (unLo > unHi) br

Re: Need advice: x86 redudant compare to zero

2005-10-13 Thread Steven Bosscher
[Sorry, pressed the wrong key combination again for the other mail... ] On Friday 14 October 2005 01:41, Evan Cheng wrote: > gcc produces the following code: You're not giving enough information for me to reproduce it. I used "-O2 -march=i686 -dAP" for the follow annotated assembler output: #(in

Re: Need advice: x86 redudant compare to zero

2005-10-13 Thread Steven Bosscher
On Friday 14 October 2005 01:41, Evan Cheng wrote: #(insn:TI 126 125 40 (parallel [ #(set (reg:SI 0 ax [71]) #(minus:SI (reg:SI 0 ax [71]) #(reg:SI 5 di))) #(clobber (reg:CC 17 flags)) #]) 242 {*subsi_1} (insn_list:REG_DEP_TRUE 12

Need advice: x86 redudant compare to zero

2005-10-13 Thread Evan Cheng
Hi, Here is a bits of code from bzip2: #define mswap(zz1, zz2) { int zztmp = zz1; zz1 = zz2; zz2 = zztmp; } void foo(int unLo, int unHi, int ltLo, int *ptr, char *block, int med, int d, int n) { while (1) { if (unLo > unHi) break; n = ((int)block[ptr[unLo]+d]) - med;