This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize memset(x, ' ', 8)
- To: Jakub Jelinek <jakub at redhat dot com>
- Subject: Re: [PATCH] Optimize memset(x, ' ', 8)
- From: Richard Henderson <rth at redhat dot com>
- Date: Fri, 1 Dec 2000 03:05:18 -0800
- Cc: ghazi at caip dot rutgers dot edu, gcc-patches at gcc dot gnu dot org
- References: <20001201110909.B552@sunsite.ms.mff.cuni.cz>
On Fri, Dec 01, 2000 at 11:09:09AM +0100, Jakub Jelinek wrote:
> + if (GET_CODE (cst) != CONST_INT
> + || (INTVAL (cst) != (char) INTVAL (cst)
> + && INTVAL (cst) != (unsigned char) INTVAL (cst)))
> + return 0;
This isn't good enough. You really wanted to be checking against
signed char and unsigned char, but you can't since K&R doesn't have
signed char.
Assuming immed_double_const has done its job, cst will be sign-extended
for the width. So you can build a test with host bits-per-char vs target
CHAR_TYPE_SIZE that directly checks the bits you need.
You'll want to make this a separate function so that you don't
duplicate this logic N times throughout the file.
The memset bits themselves are fine.
r~