This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: [PATCH] Optimize memset(x, ' ', 8)


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~

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