This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Should we optimize memset to bzero?
On Fri, Nov 02, 2001 at 06:16:08PM +0100, Jakub Jelinek wrote:
> On Fri, Nov 02, 2001 at 09:06:29AM -0800, H . J . Lu wrote:
> > On Fri, Nov 02, 2001 at 05:59:05PM +0100, Jakub Jelinek wrote:
> > > On Fri, Nov 02, 2001 at 08:51:39AM -0800, H . J . Lu wrote:
> > > > Do we have any ideas when gcc will inline __builtin_memset(s,0,n)? I don't
> > > > believe gcc will inline it if `n' is not a small constant. Can we guess what
> > > > that small constant is?
> > >
> > > Depends on exactly what processor you're compiling for.
> > > Look at gcc/expr.c (clear_storage) for all the glory details.
> > > You really don't want to have all this knowledge in glibc headers,
> > > especially when it is changing all the time.
> > >
> >
> > I doubt gcc will ever inline it if `n' is a variable. It is also very
> > unlikely for a big constant, like 256.
>
> Do you want proof? Try -Os on ia32 e.g.
> For arches which define clrstr{sd}i it can clear even with variable size,
> it is up to gcc to decide.
It is debatable if it will generate smaller code for Linux.
H.J.