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

           Summary: [4.4/4.5/4.6 Regression] GCC produces
                    unnecessary/wrong code on -O2 and -O3 levels
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: d.g.gorbac...@gmail.com
              Host: i686-pc-linux-gnu
            Target: i686-pc-linux-gnu
             Build: i686-pc-linux-gnu


$ cat > testcase.c
register int r asm("esi");

void foo(void)
{
    if (r)
        __asm__("sar\t%0" : "+r" (r));

    __asm__("sar\t%0" : "+r" (r));
}
^D
$ gcc -O2 -S testcase.c
$ cat testcase.s
[...]
foo:
.LFB0:
        xorl    %eax, %eax
        testl   %esi, %esi
        je      .L2
#APP
# 6 "testcase.c" 1
        sar     %esi
# 0 "" 2
#NO_APP
        movl    %esi, %eax
.L2:
        movl    %eax, %esi
#APP
# 8 "testcase.c" 1
        sar     %esi
# 0 "" 2
#NO_APP
        ret
[...]

Reply via email to