This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: Totally bogus string optimizations


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


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