public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Qing Zhao <qing.zhao@oracle.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	gcc-patches Nick Alcock via <gcc-patches@gcc.gnu.org>,
	"Kewen. Lin" <linkw@linux.ibm.com>,
	"H.J. Lu" <hjl.tools@gmail.com>,
	andrew Pinski <pinskia@gmail.com>
Subject: Re: Values of WIDE_INT_MAX_ELTS in gcc11 and gcc12 are different
Date: Sat, 6 Nov 2021 10:56:42 +0100	[thread overview]
Message-ID: <20211106095642.GO304296@tucnak> (raw)
In-Reply-To: <1DD8CB3D-2B99-4F02-8FB0-0027BB1042BD@oracle.com>

On Fri, Nov 05, 2021 at 05:37:25PM +0000, Qing Zhao wrote:
> > On Nov 5, 2021, at 11:17 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> > 
> > On Fri, Nov 05, 2021 at 04:11:36PM +0000, Qing Zhao wrote:
> >> 3076       if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE
> >> 3077           && tree_fits_uhwi_p (var_size)
> >> 3078           && (init_type == AUTO_INIT_PATTERN
> >> 3079               || !is_gimple_reg_type (var_type))
> >> 3080           && int_mode_for_size (tree_to_uhwi (var_size) * BITS_PER_UNIT,
> >> 3081                                 0).exists ())
> >> 3082         {
> >> 3083           unsigned HOST_WIDE_INT total_bytes = tree_to_uhwi (var_size);
> >> 3084           unsigned char *buf = (unsigned char *) xmalloc (total_bytes);
> >> 3085           memset (buf, (init_type == AUTO_INIT_PATTERN
> >> 3086                         ? INIT_PATTERN_VALUE : 0), total_bytes);
> >> 3087           tree itype = build_nonstandard_integer_type
> >> 3088                          (total_bytes * BITS_PER_UNIT, 1);
> >> 
> >> The exact failing point is at function “set_min_and_max_values_for_integral_type”:
> >> 
> >> 2851   gcc_assert (precision <= WIDE_INT_MAX_PRECISION);
> >> 
> >> For _Complex long double,  “precision” is 256.  
> >> In GCC11, “WIDE_INT_MAX_PRECISION” is 192,  in GCC12, it’s 512. 
> >> As a result, the above assertion failed on GCC11. 
> >> 
> >> I am wondering what’s the best fix for this issue in gcc11? 
> > 
> > Even for gcc 12 the above is wrong, you can't blindly assume that
> > build_nonstandard_integer_type will work for arbitrary precisions,
> > and even if it works that it will actually work.
> > The fact that such a mode exist is one thing, but
> > targetm.scalar_mode_supported_p should be tested for whether the mode
> > is actually supported.
> 
> You mean “int_mode_for_size().exists()” is not enough to make sure
> “build_nonstandard_integer_type” to be valid?  We should add
> “targetm.scalar_mode_supported_p” too ?

Yeah.  The former says whether the backend has that mode at all.
But some modes may be there only in some specific patterns but
without support for mov, add, etc.  Only for
targetm.scalar_mode_supported_p modes the backend guarantees that
one can use them e.g. in mode attribute and can expect expansion
to expand everything with that mode that is needed in some way.
E.g. only if targetm.scalar_mode_supported_p (TImode) the FEs
support __int128_t type, etc.

	Jakub


  reply	other threads:[~2021-11-06  9:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04 20:37 Qing Zhao
2021-11-05  1:34 ` Kewen.Lin
2021-11-05  6:05 ` Andrew Pinski
2021-11-05  6:53   ` Jakub Jelinek
2021-11-05 10:01     ` Richard Biener
2021-11-05 12:25       ` H.J. Lu
2021-11-05 16:11       ` Qing Zhao
2021-11-05 16:17         ` Jakub Jelinek
2021-11-05 17:37           ` Qing Zhao
2021-11-06  9:56             ` Jakub Jelinek [this message]
2021-11-08  8:41               ` Richard Biener
2021-11-08 23:47                 ` Qing Zhao
2021-11-09  7:13                   ` Richard Biener
2021-11-09  9:10                     ` Jakub Jelinek
2021-11-09 10:44                       ` Richard Biener
2021-11-09 17:19                         ` Qing Zhao
2021-11-10  8:37                           ` Richard Biener
2021-11-10 18:02                             ` Qing Zhao

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=20211106095642.GO304296@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=linkw@linux.ibm.com \
    --cc=pinskia@gmail.com \
    --cc=qing.zhao@oracle.com \
    --cc=richard.guenther@gmail.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).