This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Useless conditional branches
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 2 Mar 2010 11:42:47 +0100
- Subject: Re: Useless conditional branches
- References: <4B8CD29B.4020307@gmail.com> <4B8CE0A2.9000600@redhat.com>
On Tue, Mar 2, 2010 at 10:55 AM, Andrew Haley <aph@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 ? %edx,%edx
>> ? jne ? ?<somewhere else>
>>
>> The branch on the last line is never taken. Why does gcc generate such
>> code sequences? Is this patched at runtime, or something? Am I missing
>> something obvious here?
>
>> Let me know if more detail is needed.
>
> We really need a test case, with source, that illustrates the problem.
> When we have that, we can treat is as a missed-optimization bug.
I can't reproduce it with 4.3 nor 4.5 but indeed 4.4 has this interesting
code sequence. It looks like a missed jump threading opportunity.
Richard.
> Andrew.
>