First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 3508
Product:  
Component:  
Status: RESOLVED
Resolution: DUPLICATE of bug 12086
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: 85535-quiet@bugs.debian.org
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 3508 depends on: Show dependency tree
Show dependency graph
Bug 3508 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2001-07-01 09:26
[ Reported to the Debian BTS as report #85535.
  Please CC 85535-quiet@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/85535 ]
 	

int main() {
	return !memcmp("abcd", "efgh", 4);
}

produces the assembly (-S -g -O2),

        movl    $.LC1, %edi
        movl    $.LC0, %esi
        movl    $4, %ecx
        cld
        repz
        cmpsb
        seta    %cl
        setb    %dl
        popl    %esi
        xorl    %eax, %eax
        popl    %edi
        cmpb    %dl, %cl
        sete    %al

which is a waste because it could've simply loaded the two objects into
registers and compared them.  The same is true on other architectures as
well.

Release:
3.0 (Debian GNU/Linux) and HEAD 20010701

Environment:
System: Debian GNU/Linux (testing/unstable)
Architecture: i686
	
host: i386-linux
build: i386-linux
target: i386-linux
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux

------- Comment #1 From 85535-quiet@bugs.debian.org 2001-07-01 09:26 -------
Fix:
http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02443.html

------- Comment #2 From David Billinghurst 2002-04-22 20:39 -------
State-Changed-From-To: open->closed
State-Changed-Why: Fixed
    http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02443.html

------- Comment #3 From Debian GCC Maintainers 2003-08-10 15:31 -------
Unfortunately this bug has only been special cased rather than fixed 
in its full generality.  If we change one of the arguments to a 
variable, the compiler still fails to produce the dword comparison 
that I would expect: 
 
-- a.c -- 
int foo(const char *s) { 
        return !memcmp("abcd", s, 4); 
} 
 
-- gcc -S -O2 a.c -- 
.LC0: 
        .string "abcd" 
        .text 
        .p2align 2,,3 
.globl foo 
        .type   foo, @function 
foo: 
        pushl   %ebp 
        movl    %esp, %ebp 
        pushl   %edi 
        pushl   %esi 
        movl    8(%ebp), %edi 
        movl    $.LC0, %esi 
        movl    $4, %ecx 
        cld 
        repz 
        cmpsb 
        sete    %al 
        popl    %esi 
        movzbl  %al, %eax 
        popl    %edi 
        leave 
        ret 
        .size   foo, .-foo 
        .ident  "GCC: (GNU) 3.3 20030509 (Debian prerelease)" 
--  

------- Comment #4 From Andrew Pinski 2003-08-10 15:55 -------
Reopening because the code is not optimal in the case where only argument is
constant to 
memcmp.

------- Comment #5 From Andrew Pinski 2003-09-02 23:38 -------
Related to bug 12086.

------- Comment #6 From Andrew Pinski 2003-12-26 02:24 -------
This is a dup of bug 12086,  which should be fixed for 3.5 if I get my act
together.

*** This bug has been marked as a duplicate of 12086 ***

First Last Prev Next    No search results available      Search page      Enter new bug