This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/28946] New: assembler shifts set the flag ZF, no need to re-test to zero


etienne@cygne:~$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
 --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --
enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20060729 (prerelease) (Debian 4.1.1-10)
etienne@cygne:~$ cat tmp1.c
int fct1(void);
int fct2(void);

int fct (unsigned nb)
  {
  if ((nb >> 5) != 0)
    return fct1();
  else
    return fct2();
  }
etienne@cygne:~$ gcc -O3 -fomit-frame-pointer -S tmp1.c -o tmp1.s
etienne@cygne:~$ cat tmp1.s
        .file   "tmp1.c"
        .text
        .p2align 4,,15
.globl fct
        .type   fct, @function
fct:
        movl    4(%esp), %eax
        shrl    $5, %eax
        testl   %eax, %eax
        je      .L2
        jmp     fct1
        .p2align 4,,7
.L2:
        jmp     fct2
        .size   fct, .-fct
        .ident  "GCC: (GNU) 4.1.2 20060729 (prerelease) (Debian 4.1.1-10)"
        .section        .note.GNU-stack,"",@progbits
etienne@cygne:~$

 The assembly instruction "testl %eax, %eax" is not needed considering the
Intel documentation of "SAL/SAR/SHL/SHR", "Flags Affected":
The SF, ZF, and PF flags are set according to the result.


-- 
           Summary: assembler shifts set the flag ZF, no need to re-test to
                    zero
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: etienne_lorrain at yahoo dot fr
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]