public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-8303] lower-bitint: Handle INTEGER_CST rhs1 in handle_cast [PR113462]
Date: Sat, 20 Jan 2024 11:37:28 +0000 (GMT)	[thread overview]
Message-ID: <20240120113729.6A82C3858D39@sourceware.org> (raw)

https://gcc.gnu.org/g:efc677f3e78abf02264e4a64c751b4ecdc918ec9

commit r14-8303-gefc677f3e78abf02264e4a64c751b4ecdc918ec9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Jan 20 12:36:32 2024 +0100

    lower-bitint: Handle INTEGER_CST rhs1 in handle_cast [PR113462]
    
    The following patch ICEs because fre3 leaves around unfolded
      _1 = VIEW_CONVERT_EXPR<_BitInt(129)>(0);
    statement and in handle_cast I was expecting just SSA_NAMEs for the
    large/huge _BitInt to large/huge _BitInt casts; INTEGER_CST is something
    we can handle in that case exactly the same, as the handle_operand recursion
    handles those.
    
    Of course, maybe we should also try to fold_stmt such cases somewhere in
    bitint lowering preparation.
    
    2024-01-20  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/113462
            * gimple-lower-bitint.cc (bitint_large_huge::handle_cast):
            Handle rhs1 INTEGER_CST like SSA_NAME.
    
            * gcc.dg/bitint-76.c: New test.

Diff:
---
 gcc/gimple-lower-bitint.cc       |  2 +-
 gcc/testsuite/gcc.dg/bitint-76.c | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index be11d77fe4d..298f16ef8da 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -1250,7 +1250,7 @@ bitint_large_huge::handle_cast (tree lhs_type, tree rhs1, tree idx)
 {
   tree rhs_type = TREE_TYPE (rhs1);
   gimple *g;
-  if (TREE_CODE (rhs1) == SSA_NAME
+  if ((TREE_CODE (rhs1) == SSA_NAME || TREE_CODE (rhs1) == INTEGER_CST)
       && TREE_CODE (lhs_type) == BITINT_TYPE
       && TREE_CODE (rhs_type) == BITINT_TYPE
       && bitint_precision_kind (lhs_type) >= bitint_prec_large
diff --git a/gcc/testsuite/gcc.dg/bitint-76.c b/gcc/testsuite/gcc.dg/bitint-76.c
new file mode 100644
index 00000000000..23f118adddf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-76.c
@@ -0,0 +1,16 @@
+/* PR tree-optimization/113462 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c23 -O2" } */
+
+#if __BITINT_MAXWIDTH__ >= 129
+typedef _BitInt(129) B;
+#else
+typedef _BitInt(63) B;
+#endif
+
+B
+foo (void)
+{
+  struct { B b; } s = {};
+  return s.b;
+}

                 reply	other threads:[~2024-01-20 11:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240120113729.6A82C3858D39@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).