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 target/33555] New: x86 missed opportunity for sbb


> /usr/local/gcc43/bin/gcc -v
Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: ../gcc/configure --prefix=/usr/local/gcc43 --with-arch=nocona
--with-tune=nocona --with-gmp=/sw --with-system-zlib
--enable-languages=c,c++,objc,obj-c++
Thread model: posix
gcc version 4.3.0 20070925 (experimental) (GCC) 

> /usr/local/gcc43/bin/gcc -Os -fno-pic -S sbb.c -fomit-frame-pointer
        .text
.globl _cmpb_sbb
_cmpb_sbb:
        subl    $12, %esp
        movl    16(%esp), %eax
        movl    20(%esp), %ecx
        xorl    %edx, %edx
        cmpl    24(%esp), %ecx
        setb   %dl
        negl    %edx
        andl    %ecx, %edx
        subl    %edx, %eax
        addl    $12, %esp
        ret
        .subsections_via_symbols

Source:
unsigned cmpb_sbb(unsigned a, unsigned b, unsigned c)
{
        unsigned mask = -(b < c);

        a -= b & mask;
        return a;
}

"setb, negl" is the same as 0 - (0 + eflags.CF), so it can be replaced with
"sbb %edx, %edx".
This is useful for if-conversion, since it's the same as "if (b < c) a -= b;"


-- 
           Summary: x86 missed opportunity for sbb
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: astrange at ithinksw dot com
 GCC build triplet: i386-apple-darwin8.10.1
  GCC host triplet: i386-apple-darwin8.10.1
GCC target triplet: i386-apple-darwin8.10.1


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


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