This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Totally bogus string optimizations
- To: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Subject: Re: Totally bogus string optimizations
- From: Bernd Schmidt <bernds at redhat dot co dot uk>
- Date: Sat, 28 Oct 2000 20:26:46 +0100 (BST)
- cc: Ulrich Drepper <drepper at cygnus dot com>, libc-alpha at sourceware dot cygnus dot com, gcc-bugs at gcc dot gnu dot org
On Sat, 28 Oct 2000, Joseph S. Myers wrote:
> If this gets improved in GCC, then the strcpy macro should best be
> disabled for GCC 2.97 and later: the code generated by the macro in GCC
> CVS is terrible:
>
> .LC0:
> .string "Foobar"
> .text
> .align 16
> .globl foo
> .type foo,@function
> foo:
> movl $.LC0+1, %eax
> subl $12, %esp
> cmpl %eax, %eax
> je .L158
Note that there's definitely a bug in gcc's constant folding here. This is the
part of the macro that tries to determine whether the string is made of 1 unit
wide characters by doing
(((char *)&"Foobar"[1]) - (char *)&"Foobar"[0]) == 1
and gcc ought to optimize this away.
> while GCC 2.95.2 generates with the macro the code we want, apart from
> leaving the string constant in the code (so there *is* a regression in
> GCC):
Yes. All this, however, is with the unaligned version of the strcpy macro.
The aligned version generates completely bogus code with all gcc versions I've
tried (2.7.2.3, 2.95.2, current).
Bernd