This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Additional builtin memset optimization
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 21 Apr 2002 17:44:20 -0700
- Subject: Re: [PATCH] Additional builtin memset optimization
- References: <Pine.LNX.4.33.0204211552350.20378-100000@www.eyesopen.com>
On Sun, Apr 21, 2002 at 04:39:25PM -0600, Roger Sayle wrote:
>
> The patch improves the code generated by built-in memset, when
> the length is a compile time constant, but the value isn't.
> Depending upon the alignment of the buffer, the compiler will
> perform a sequence of byte stores of the value c, short stores
> of c * 0x0101, or word stores of c * 0x0101, where c is the
> run-time value argument cast to an unsigned char.
Is there any reason to limit this to 32-bit words? It seems likely to
me that the alpha could benefit from doing 64-bit stores when
alignment cooperates, frex
> extern int buffer[4];
> void bar(int c) { memset(buffer,c,16); }
if that was extern long buffer[2], we could do another sll/addq pair
and just two store operations.
Also, I note that the glibc sysdeps/alpha/memset.S uses stq_u
operations -- dunno if it would be worthwhile to do that here.
zw