On Mon, Oct 26, 2020 at 10:14 AM Jan Hubicka <hubi...@ucw.cz> wrote:
>
> > >
> > > For example you had patch that limited "rep cmpsb" expansion for
> > > -minline-all-stringops.  Now the conditions could be
> > > -minline-all-stringops || optimize_insn_for_size () == OPTIMIZE_SIZE_MAX
> > > since it is still useful size optimization.
> > >
> > > I am not sure if you had other changes of this nature? (It is bit hard
> > > to grep compiler for things like this and I would like to get these
> > > organized to optimize_size levels now).
> >
> > Shouldn't it apply to all functions inlined by -minline-all-stringops?
>
> I think we handle the other cases, for code optimized for size we go for
> ix86_size_memcpy and ix86_size_memset tables that say inline all with
> rep movsb.  We do not inline strlen since the way it is implemented gets
> too long (short inline version would be welcome).
>
> I will look through backend, but if you are aware of more checks like
> one in ix86_expand_cmpstrn_or_cmpmem which disable size optimization
> even at -Os, let me know.  They are not that easy to find...
>

[hjl@gnu-cfl-2 gcc]$ cat /tmp/x.c
int
func (char *d, unsigned int l)
{
  return __builtin_strncmp (d, "foo", l) ? 1 : 2;
}
[hjl@gnu-cfl-2 gcc]$ gcc -c -Os  /tmp/x.c
[hjl@gnu-cfl-2 gcc]$ nm x.o
0000000000000000 T func
                 U strncmp
[hjl@gnu-cfl-2 gcc]$ size x.o
   text    data     bss     dec     hex filename
    138       0       0     138      8a x.o
[hjl@gnu-cfl-2 gcc]$ gcc -c -O2  /tmp/x.c
[hjl@gnu-cfl-2 gcc]$ size x.o
   text    data     bss     dec     hex filename
    146       0       0     146      92 x.o
[hjl@gnu-cfl-2 gcc]$ nm x.o
0000000000000000 T func
[hjl@gnu-cfl-2 gcc]$

-Os shouldn't inline strncmp.

-- 
H.J.

Reply via email to