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 r12-8496] varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]
Date: Sun, 19 Jun 2022 10:09:07 +0000 (GMT)	[thread overview]
Message-ID: <20220619100907.CB2BF3851A9B@sourceware.org> (raw)

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

commit r12-8496-ge8df0d960b36146c8e193b269f9f7ae7dc76e08b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Jun 18 11:07:13 2022 +0200

    varasm: Fix up ICE in narrowing_initializer_constant_valid_p [PR105998]
    
    The following testcase ICEs because there is NON_LVALUE_EXPR (location
    wrapper) around a VAR_DECL and has TYPE_MODE V2SImode and
    SCALAR_INT_TYPE_MODE on that ICEs.  Or for -m32 -march=i386 TYPE_MODE
    is DImode, but SCALAR_INT_TYPE_MODE still uses the raw V2SImode and ICEs
    too.
    
    2022-06-18  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/105998
            * varasm.cc (narrowing_initializer_constant_valid_p): Check
            SCALAR_INT_MODE_P instead of INTEGRAL_MODE_P, also break on
            ! INTEGRAL_TYPE_P and do the same check also on op{0,1}'s type.
    
            * c-c++-common/pr105998.c: New test.
    
    (cherry picked from commit ef662120177d39af5f88ffc622d90bb6ae0ca1d3)

Diff:
---
 gcc/testsuite/c-c++-common/pr105998.c | 12 ++++++++++++
 gcc/varasm.cc                         | 10 ++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/pr105998.c b/gcc/testsuite/c-c++-common/pr105998.c
new file mode 100644
index 00000000000..85277b97007
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr105998.c
@@ -0,0 +1,12 @@
+/* PR middle-end/105998 */
+
+typedef int __attribute__((__vector_size__ (sizeof (long long)))) V;
+
+V v;
+
+long long
+foo (void)
+{
+  long long l = (long long) ((0 | v) - ((V) { } == 0));
+  return l;
+}
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index c41f17d64f7..021e912a37c 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -4716,7 +4716,10 @@ narrowing_initializer_constant_valid_p (tree value, tree endtype, tree *cache)
     {
       tree inner = TREE_OPERAND (op0, 0);
       if (inner == error_mark_node
-	  || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
+	  || ! INTEGRAL_TYPE_P (TREE_TYPE (op0))
+	  || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op0)))
+	  || ! INTEGRAL_TYPE_P (TREE_TYPE (inner))
+	  || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
 	  || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op0)))
 	      > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
 	break;
@@ -4728,7 +4731,10 @@ narrowing_initializer_constant_valid_p (tree value, tree endtype, tree *cache)
     {
       tree inner = TREE_OPERAND (op1, 0);
       if (inner == error_mark_node
-	  || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
+	  || ! INTEGRAL_TYPE_P (TREE_TYPE (op1))
+	  || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (op1)))
+	  || ! INTEGRAL_TYPE_P (TREE_TYPE (inner))
+	  || ! SCALAR_INT_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
 	  || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op1)))
 	      > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
 	break;


                 reply	other threads:[~2022-06-19 10:09 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=20220619100907.CB2BF3851A9B@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).