+++ This bug was initially created as a clone of Bug #20517 +++

>From comment #4:

----- testcase.c -----
_Bool foo(unsigned i)
{
        return (i >> 5) > 10;
}

_Bool bar(unsigned i)
{
        return i > (10 << 5) + 31;
}

int fooi(unsigned i)
{
        return (i >> 5) > 10;
}

int bari(unsigned i)
{
        return i > (10 << 5) + 31;
}
----------------------

Compiled with:
$ gcc-4.6.0-pre9999 tst6.c -O3 -S -m32 -fomit-frame-pointer
(svn r162190)

Results in:
foo:
        movl    4(%esp), %eax
        shrl    $5, %eax
        cmpl    $10, %eax
        seta    %al
        ret
bar:
        cmpl    $351, 4(%esp)
        seta    %al
        ret
fooi:
        movl    4(%esp), %eax
        shrl    $5, %eax
        cmpl    $10, %eax
        seta    %al
        movzbl  %al, %eax
        ret
bari:
        xorl    %eax, %eax
        cmpl    $351, 4(%esp)
        seta    %al
        ret


-- 
           Summary: optimize bit shift+compare at RTL level
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: zsojka at seznam dot cz
GCC target triplet: x86(_64)-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45617

Reply via email to