Useless conditional branches

2010-03-02 Thread Alain Ketterlin
It looks like gcc sometimes produces useless conditional branches. I've found code like this: xor%edx,%edx ; code with no effect on edx (see full code below) test %edx,%edx jnesomewhere else The branch on the last line is never taken. Why does gcc generate such code sequences

Re: Useless conditional branches

2010-03-02 Thread Piotr Wyderski
Alain Ketterlin wrote: I've found code like this:  xor    %edx,%edx  ; code with no effect on edx (see full code below)  test   %edx,%edx  jne    somewhere else I have experienced similar sequences where your code with no effect was a lot of SSE instructions, so I can confirm that the

Re: Useless conditional branches

2010-03-02 Thread Andrew Haley
On 03/02/2010 08:55 AM, Alain Ketterlin wrote: It looks like gcc sometimes produces useless conditional branches. I've found code like this: xor%edx,%edx ; code with no effect on edx (see full code below) test %edx,%edx jnesomewhere else The branch on the last line

Re: Useless conditional branches

2010-03-02 Thread Alain Ketterlin
Andrew Haley wrote: On 03/02/2010 08:55 AM, Alain Ketterlin wrote: It looks like gcc sometimes produces useless conditional branches. I've found code like this: xor%edx,%edx ; code with no effect on edx (see full code below) test %edx,%edx jnesomewhere else The branch

Re: Useless conditional branches

2010-03-02 Thread Richard Guenther
On Tue, Mar 2, 2010 at 10:55 AM, Andrew Haley a...@redhat.com wrote: On 03/02/2010 08:55 AM, Alain Ketterlin wrote: It looks like gcc sometimes produces useless conditional branches. I've found code like this:   xor    %edx,%edx   ; code with no effect on edx (see full code below)   test