public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] c-family: Tighten vector handling in type_for_mode [PR94072]
@ 2020-03-30 11:00 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2020-03-30 11:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1aa22b1916a493ac46453d96e0c78ca47bcaeda3

commit 1aa22b1916a493ac46453d96e0c78ca47bcaeda3
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Tue Mar 17 14:43:08 2020 +0000

    c-family: Tighten vector handling in type_for_mode [PR94072]
    
    In this PR we had a 512-bit VECTOR_TYPE whose mode is XImode
    (an integer mode used for four 128-bit vectors).  When trying
    to expand a zero constant for it, we hit code in expand_expr_real_1
    that tries to use the associated integer type instead.  The code used
    type_for_mode (XImode, 1) to get this integer type.
    
    However, the c-family implementation of type_for_mode checks for
    any registered built-in type that matches the mode and has the
    right signedness.  This meant that it could return a built-in
    vector type when given an integer mode (particularly if, as here,
    the vector type isn't supported by the current subtarget and so
    TYPE_MODE != TYPE_MODE_RAW).  The expand code would then cycle
    endlessly trying to use this "new" type instead of the original
    vector type.
    
    2020-03-20  Richard Sandiford  <richard.sandiford@arm.com>
    
    gcc/c-family/
            PR middle-end/94072
            * c-common.c (c_common_type_for_mode): Before using a registered
            built-in type, check that the vectorness of the type matches
            the vectorness of the mode.
    
    gcc/testsuite/
            PR middle-end/94072
            * gcc.target/aarch64/pr94072.c: New test.

Diff:
---
 gcc/c-family/ChangeLog                     |  7 +++++++
 gcc/c-family/c-common.c                    | 11 +++++++----
 gcc/testsuite/ChangeLog                    |  5 +++++
 gcc/testsuite/gcc.target/aarch64/pr94072.c |  9 +++++++++
 4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 59661ef24e8..3f195ebcc5d 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,10 @@
+2020-03-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR middle-end/94072
+	* c-common.c (c_common_type_for_mode): Before using a registered
+	built-in type, check that the vectorness of the type matches
+	the vectorness of the mode.
+
 2020-03-17  Jakub Jelinek  <jakub@redhat.com>
 
 	* c-common.c (resolve_overloaded_builtin): Fix up duplicated word
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 25020bf1415..8e5a9243827 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -2387,10 +2387,13 @@ c_common_type_for_mode (machine_mode mode, int unsignedp)
     }
 
   for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
-    if (TYPE_MODE (TREE_VALUE (t)) == mode
-	&& !!unsignedp == !!TYPE_UNSIGNED (TREE_VALUE (t)))
-      return TREE_VALUE (t);
-
+    {
+      tree type = TREE_VALUE (t);
+      if (TYPE_MODE (type) == mode
+	  && VECTOR_TYPE_P (type) == VECTOR_MODE_P (mode)
+	  && !!unsignedp == !!TYPE_UNSIGNED (type))
+	return type;
+    }
   return NULL_TREE;
 }
 
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 540ec67b862..2408590cc51 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR middle-end/94072
+	* gcc.target/aarch64/pr94072.c: New test.
+
 2020-03-20  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
             Andre Vieira  <andre.simoesdiasvieira@arm.com>
             Mihail Ionescu  <mihail.ionescu@arm.com>
diff --git a/gcc/testsuite/gcc.target/aarch64/pr94072.c b/gcc/testsuite/gcc.target/aarch64/pr94072.c
new file mode 100644
index 00000000000..2aa72eb7a16
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr94072.c
@@ -0,0 +1,9 @@
+/* { dg-options "-msve-vector-bits=512" } */
+
+#pragma GCC target "+nosve"
+
+void
+foo (void)
+{
+  (int __attribute__ ((__vector_size__ (64)))){};
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-30 11:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 11:00 [gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] c-family: Tighten vector handling in type_for_mode [PR94072] Martin Liska

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).