public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: Bill Schmidt <wschmidt@linux.vnet.ibm.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PR 79905] ICE with vector_type
Date: Wed, 05 Apr 2017 14:14:00 -0000	[thread overview]
Message-ID: <1b0a9ef8-dfe6-d289-2ee9-7108822454e4@acm.org> (raw)
In-Reply-To: <4DC65C33-038F-430C-8531-15B318861071@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 224 bytes --]


> Thanks for the patch!  Looks like there are some compile problems.  I can fix "resut", but not sure what the intent is for "canonical":

I'm a dumbass.  I built the x86_64 compiler :(
try this.

nathan
-- 
Nathan Sidwell

[-- Attachment #2: ppc-79905.diff --]
[-- Type: text/x-patch, Size: 8728 bytes --]

2017-04-05  Nathan Sidwell  <nathan@acm.org>

	PR target/79905
	* config/rs6000/rs6000.c (rs6000_vt): New.
	(rs6000_init_builtins): Use it.

	c-family/
	* c-common.c (set_underlying_type): Make builtin type-copy when
	name is error_mark.

	testsuite/
	* g++.dg/torture/pr79905.C: New.

Index: c-family/c-common.c
===================================================================
--- c-family/c-common.c	(revision 246647)
+++ c-family/c-common.c	(working copy)
@@ -7465,7 +7465,12 @@ set_underlying_type (tree x)
 {
   if (x == error_mark_node)
     return;
-  if (DECL_IS_BUILTIN (x) && TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE)
+  if (DECL_IS_BUILTIN (x)
+      && TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE
+      /* Callers set name to error_mark_node to force the builtin to
+	 have a type copy.  That ensures the canonical type doesn't
+	 get a name.  */
+      && TYPE_NAME (TREE_TYPE (x)) != error_mark_node)
     {
       if (TYPE_NAME (TREE_TYPE (x)) == 0)
 	TYPE_NAME (TREE_TYPE (x)) = x;
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 246647)
+++ config/rs6000/rs6000.c	(working copy)
@@ -17257,6 +17257,29 @@ rs6000_expand_builtin (tree exp, rtx tar
   gcc_unreachable ();
 }
 
+/* Create a builtin vector type with a name.  Taking care not to give
+   the canonical type a name.  */
+
+static tree
+rs6000_vt (const char *name, tree elt_type, unsigned num_elts)
+{
+  tree result = build_vector_type (elt_type, num_elts);
+  tree orig_name = TYPE_NAME (result);
+
+  /* Tell set_underlying_type to create a clone.  */
+  TYPE_NAME (result) = error_mark_node;
+  tree named_type = add_builtin_type (name, result);
+  TYPE_NAME (result) = orig_name;
+  if (named_type)
+    {
+      gcc_assert (TREE_TYPE (named_type) != result);
+      result = TREE_TYPE (named_type);
+      TREE_USED (result) = true;
+    }
+  
+  return result;
+}
+
 static void
 rs6000_init_builtins (void)
 {
@@ -17273,18 +17296,25 @@ rs6000_init_builtins (void)
 
   V2SI_type_node = build_vector_type (intSI_type_node, 2);
   V2SF_type_node = build_vector_type (float_type_node, 2);
-  V2DI_type_node = build_vector_type (intDI_type_node, 2);
-  V2DF_type_node = build_vector_type (double_type_node, 2);
+  V2DI_type_node = rs6000_vt (TARGET_POWERPC64 ? "__vector long"
+			      : "__vector long long", intDI_type_node, 2);
+  V2DF_type_node = rs6000_vt ("__vector double", double_type_node, 2);
   V4HI_type_node = build_vector_type (intHI_type_node, 4);
-  V4SI_type_node = build_vector_type (intSI_type_node, 4);
-  V4SF_type_node = build_vector_type (float_type_node, 4);
-  V8HI_type_node = build_vector_type (intHI_type_node, 8);
-  V16QI_type_node = build_vector_type (intQI_type_node, 16);
-
-  unsigned_V16QI_type_node = build_vector_type (unsigned_intQI_type_node, 16);
-  unsigned_V8HI_type_node = build_vector_type (unsigned_intHI_type_node, 8);
-  unsigned_V4SI_type_node = build_vector_type (unsigned_intSI_type_node, 4);
-  unsigned_V2DI_type_node = build_vector_type (unsigned_intDI_type_node, 2);
+  V4SI_type_node = rs6000_vt ("__vector signed int", intSI_type_node, 4);
+  V4SF_type_node = rs6000_vt ("__vector float", float_type_node, 4);
+  V8HI_type_node = rs6000_vt ("__vector signed short", intHI_type_node, 8);
+  V16QI_type_node = rs6000_vt ("__vector signed char", intQI_type_node, 16);
+
+  unsigned_V16QI_type_node = rs6000_vt ("__vector unsigned char",
+					unsigned_intQI_type_node, 16);
+  unsigned_V8HI_type_node = rs6000_vt ("__vector unsigned short",
+				       unsigned_intHI_type_node, 8);
+  unsigned_V4SI_type_node = rs6000_vt ("__vector unsigned int",
+				       unsigned_intSI_type_node, 4);
+  unsigned_V2DI_type_node = rs6000_vt (TARGET_POWERPC64
+				       ? "__vector unsigned long"
+				       : "__vector unsigned long long",
+				       unsigned_intDI_type_node, 2);
 
   opaque_V2SF_type_node = build_opaque_vector_type (float_type_node, 2);
   opaque_V2SI_type_node = build_opaque_vector_type (intSI_type_node, 2);
@@ -17299,8 +17329,9 @@ rs6000_init_builtins (void)
      must live in VSX registers.  */
   if (intTI_type_node)
     {
-      V1TI_type_node = build_vector_type (intTI_type_node, 1);
-      unsigned_V1TI_type_node = build_vector_type (unsigned_intTI_type_node, 1);
+      V1TI_type_node = rs6000_vt ("__vector __int128", intTI_type_node, 1);
+      unsigned_V1TI_type_node = rs6000_vt ("__vector unsigned __int128",
+					   unsigned_intTI_type_node, 1);
     }
 
   /* The 'vector bool ...' types must be kept distinct from 'vector unsigned ...'
@@ -17432,83 +17463,16 @@ rs6000_init_builtins (void)
   tdecl = add_builtin_type ("__pixel", pixel_type_node);
   TYPE_NAME (pixel_type_node) = tdecl;
 
-  bool_V16QI_type_node = build_vector_type (bool_char_type_node, 16);
-  bool_V8HI_type_node = build_vector_type (bool_short_type_node, 8);
-  bool_V4SI_type_node = build_vector_type (bool_int_type_node, 4);
-  bool_V2DI_type_node = build_vector_type (bool_long_type_node, 2);
-  pixel_V8HI_type_node = build_vector_type (pixel_type_node, 8);
-
-  tdecl = add_builtin_type ("__vector unsigned char", unsigned_V16QI_type_node);
-  TYPE_NAME (unsigned_V16QI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector signed char", V16QI_type_node);
-  TYPE_NAME (V16QI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector __bool char", bool_V16QI_type_node);
-  TYPE_NAME (bool_V16QI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector unsigned short", unsigned_V8HI_type_node);
-  TYPE_NAME (unsigned_V8HI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector signed short", V8HI_type_node);
-  TYPE_NAME (V8HI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector __bool short", bool_V8HI_type_node);
-  TYPE_NAME (bool_V8HI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector unsigned int", unsigned_V4SI_type_node);
-  TYPE_NAME (unsigned_V4SI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector signed int", V4SI_type_node);
-  TYPE_NAME (V4SI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector __bool int", bool_V4SI_type_node);
-  TYPE_NAME (bool_V4SI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector float", V4SF_type_node);
-  TYPE_NAME (V4SF_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector __pixel", pixel_V8HI_type_node);
-  TYPE_NAME (pixel_V8HI_type_node) = tdecl;
-
-  tdecl = add_builtin_type ("__vector double", V2DF_type_node);
-  TYPE_NAME (V2DF_type_node) = tdecl;
-
-  if (TARGET_POWERPC64)
-    {
-      tdecl = add_builtin_type ("__vector long", V2DI_type_node);
-      TYPE_NAME (V2DI_type_node) = tdecl;
-
-      tdecl = add_builtin_type ("__vector unsigned long",
-				unsigned_V2DI_type_node);
-      TYPE_NAME (unsigned_V2DI_type_node) = tdecl;
-
-      tdecl = add_builtin_type ("__vector __bool long", bool_V2DI_type_node);
-      TYPE_NAME (bool_V2DI_type_node) = tdecl;
-    }
-  else
-    {
-      tdecl = add_builtin_type ("__vector long long", V2DI_type_node);
-      TYPE_NAME (V2DI_type_node) = tdecl;
-
-      tdecl = add_builtin_type ("__vector unsigned long long",
-				unsigned_V2DI_type_node);
-      TYPE_NAME (unsigned_V2DI_type_node) = tdecl;
-
-      tdecl = add_builtin_type ("__vector __bool long long",
-				bool_V2DI_type_node);
-      TYPE_NAME (bool_V2DI_type_node) = tdecl;
-    }
-
-  if (V1TI_type_node)
-    {
-      tdecl = add_builtin_type ("__vector __int128", V1TI_type_node);
-      TYPE_NAME (V1TI_type_node) = tdecl;
-
-      tdecl = add_builtin_type ("__vector unsigned __int128",
-				unsigned_V1TI_type_node);
-      TYPE_NAME (unsigned_V1TI_type_node) = tdecl;
-    }
+  bool_V16QI_type_node = rs6000_vt ("__vector __bool char",
+				    bool_char_type_node, 16);
+  bool_V8HI_type_node = rs6000_vt ("__vector __bool short",
+				   bool_short_type_node, 8);
+  bool_V4SI_type_node = rs6000_vt ("__vector __bool int",
+				   bool_int_type_node, 4);
+  bool_V2DI_type_node = rs6000_vt (TARGET_POWERPC64 ? "__vector __bool long"
+				   : "__vector __bool long long",
+				   bool_long_type_node, 2);
+  pixel_V8HI_type_node = rs6000_vt ("__vector __pixel", pixel_type_node, 8);
 
   /* Paired and SPE builtins are only available if you build a compiler with
      the appropriate options, so only create those builtins with the
Index: testsuite/g++.dg/torture/pr79905.C
===================================================================
--- testsuite/g++.dg/torture/pr79905.C	(revision 0)
+++ testsuite/g++.dg/torture/pr79905.C	(working copy)
@@ -0,0 +1,9 @@
+// PR target/79905
+// { dg-do compile { target { powerpc*-*-* } } }
+
+
+typedef int V4i __attribute__((vector_size(16)));
+void a (V4i) {
+  vector int b;
+  a (b);
+}

  reply	other threads:[~2017-04-05 14:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-03 19:03 Nathan Sidwell
2017-04-04  8:28 ` Richard Biener
2017-04-04 11:31   ` Nathan Sidwell
2017-04-04 13:00     ` Richard Biener
2017-04-04 13:49       ` Nathan Sidwell
2017-04-04 13:57         ` Bill Schmidt
2017-04-04 14:02           ` Nathan Sidwell
2017-04-04 17:40             ` Bill Schmidt
2017-04-04 18:02               ` Nathan Sidwell
2017-04-04 20:46                 ` Bill Schmidt
2017-04-05 13:18                   ` Nathan Sidwell
2017-04-05 13:35                     ` Bill Schmidt
2017-04-05 14:14                       ` Nathan Sidwell [this message]
2017-04-05 20:33                         ` Bill Schmidt
2017-04-06 10:29                           ` Richard Biener
2017-04-06 11:28                             ` Nathan Sidwell
2017-04-06 14:04                               ` Richard Biener
2017-04-06 14:20                                 ` Bill Schmidt
2017-04-06 14:26                                   ` Bill Schmidt
2017-04-06 15:13                                     ` Bill Schmidt
2017-04-06 18:34                                       ` Nathan Sidwell
2017-04-06 20:18                                         ` Segher Boessenkool
2017-04-10 11:24                                           ` Nathan Sidwell

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=1b0a9ef8-dfe6-d289-2ee9-7108822454e4@acm.org \
    --to=nathan@acm.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    --cc=wschmidt@linux.vnet.ibm.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).