public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] sccvn: Don't use SCALAR_INT_TYPE_MODE on BLKmode BITINT_TYPEs [PR113459]
Date: Fri, 19 Jan 2024 09:55:27 +0100 (CET)	[thread overview]
Message-ID: <s6sr0spq-78rp-34o1-nqs3-8o3562qp1n3s@fhfr.qr> (raw)
In-Reply-To: <Zao2xzabzjaMp2os@tucnak>

On Fri, 19 Jan 2024, Jakub Jelinek wrote:

> Hi!
> 
> sccvn uses GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)) for INTEGER_TYPEs,
> most likely because that is what native_{interpret,encode}_int used.
> This obviously doesn't work for larger BITINT_TYPEs which have BLKmode
> and the above ICEs on those.  native_{interpret,encode}_int checks whether
> the BITINT_TYPE is medium/large/huge (i.e. an array of 2+ ABI limbs)
> and uses TYPE_SIZE_UNIT for that case, otherwise SCALAR_INT_TYPE_MODE like
> for the INTEGER_TYPE case.
> 
> The following patch instead just uses SCALAR_INT_TYPE_MODE for non-BLKmode
> TYPE_MODE and TYPE_SIZE_UNIT otherwise.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Thanks,
Richard.

> 2024-01-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/113459
> 	* tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def): Use
> 	TREE_INT_CST_LOW of TYPE_SIZE_UNIT rather than GET_MODE_SIZE
> 	of SCALAR_INT_TYPE_MODE if type has BLKmode.
> 	(vn_reference_lookup_3): Likewise.  Formatting fix.
> 
> 	* gcc.dg/bitint-73.c: New test.
> 
> --- gcc/tree-ssa-sccvn.cc.jj	2024-01-03 11:51:42.361580881 +0100
> +++ gcc/tree-ssa-sccvn.cc	2024-01-18 12:39:52.789606975 +0100
> @@ -2287,7 +2287,12 @@ vn_walk_cb_data::push_partial_def (pd_da
>  				    BITS_PER_UNIT
>  				    - (maxsizei % BITS_PER_UNIT));
>        if (INTEGRAL_TYPE_P (type))
> -	sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type));
> +	{
> +	  if (TYPE_MODE (type) != BLKmode)
> +	    sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type));
> +	  else
> +	    sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
> +	}
>        if (sz > needed_len)
>  	{
>  	  memcpy (this_buffer + (sz - needed_len), buffer, needed_len);
> @@ -2967,8 +2972,10 @@ vn_reference_lookup_3 (ao_ref *ref, tree
>  	    }
>  	  else
>  	    {
> -	      unsigned buflen = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (vr->type)) + 1;
> -	      if (INTEGRAL_TYPE_P (vr->type))
> +	      unsigned buflen
> +		= TREE_INT_CST_LOW (TYPE_SIZE_UNIT (vr->type)) + 1;
> +	      if (INTEGRAL_TYPE_P (vr->type)
> +		  && TYPE_MODE (vr->type) != BLKmode)
>  		buflen = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (vr->type)) + 1;
>  	      unsigned char *buf = XALLOCAVEC (unsigned char, buflen);
>  	      memset (buf, TREE_INT_CST_LOW (gimple_call_arg (def_stmt, 1)),
> @@ -3165,7 +3172,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree
>  			 offset + maxsize - 1.  */
>  		      HOST_WIDE_INT sz = maxsizei / BITS_PER_UNIT;
>  		      if (INTEGRAL_TYPE_P (type))
> -			sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type));
> +			{
> +			  if (TYPE_MODE (type) != BLKmode)
> +			    sz = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type));
> +			  else
> +			    sz = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (type));
> +			}
>  		      amnt = ((unsigned HOST_WIDE_INT) offset2i + size2i
>  			      - offseti - maxsizei) % BITS_PER_UNIT;
>  		      if (amnt)
> --- gcc/testsuite/gcc.dg/bitint-73.c.jj	2024-01-18 12:29:07.586634031 +0100
> +++ gcc/testsuite/gcc.dg/bitint-73.c	2024-01-18 12:28:42.406986342 +0100
> @@ -0,0 +1,18 @@
> +/* PR tree-optimization/113459 */
> +/* { dg-do compile { target bitint } } */
> +/* { dg-options "-std=c23 -O2" } */
> +
> +#if __BITINT_MAXWIDTH__ >= 129
> +# define N 129
> +#else
> +# define N 63
> +#endif
> +
> +_BitInt(N) a;
> +
> +_BitInt(N)
> +foo (void)
> +{
> +  __builtin_memset (&a, 6, sizeof a);
> +  return a;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

      reply	other threads:[~2024-01-19  8:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19  8:45 Jakub Jelinek
2024-01-19  8:55 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s6sr0spq-78rp-34o1-nqs3-8o3562qp1n3s@fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).