This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memset and host char requirement
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: "Paulo J. Matos" <paulo at matos-sorge dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 26 Jul 2012 14:27:25 +0200
- Subject: Re: memset and host char requirement
- References: <jurc4u$ql$1@dough.gmane.org>
On Thu, Jul 26, 2012 at 2:11 PM, Paulo J. Matos <paulo@matos-sorge.com> wrote:
> Hi,
>
> My target has 16bit chars.
> What I am seeing is that in a memset call, the call is not inlined by GCC
> whenever fill value is bigger than host char.
>
> This seems to be due to the code (GCC 4.6.5) in target_char_cast
> (builtins.c), called from expand_builtin_memset_args:
>
> static int
> target_char_cast (tree cst, char *p)
> {
> unsigned HOST_WIDE_INT val, hostval;
>
> if (TREE_CODE (cst) != INTEGER_CST
> || CHAR_TYPE_SIZE > HOST_BITS_PER_WIDE_INT)
> return 1;
>
> val = TREE_INT_CST_LOW (cst);
> if (CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT)
> val &= (((unsigned HOST_WIDE_INT) 1) << CHAR_TYPE_SIZE) - 1;
>
> hostval = val;
> if (HOST_BITS_PER_CHAR < HOST_BITS_PER_WIDE_INT)
> hostval &= (((unsigned HOST_WIDE_INT) 1) << HOST_BITS_PER_CHAR) - 1;
>
> if (val != hostval)
> return 1;
>
> *p = hostval;
> return 0;
> }
>
>
> This requires the tree cst variable to fit in target char (which makes
> sense) and in host char (which doesn't make sense).
>
> Why would the fill value in a memset call be required to fit in a host char?
Obviously because of the implementation detail of its caller.
Richard.
> Cheers,
>
> --
> PMatos
>
>