diff mbox

Go patch committed: Handle vector modes

Message ID mcrlj41pefh.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Dec. 7, 2010, 7:32 p.m. UTC
The tree vectorizer calls the type_for_mode langhook with vector modes.
I'm not sure this makes sense.  If a language doesn't have any vector
types, then there is nothing sensible that the langhook can return.  It
seems to me that this should be done entirely in the middle-end, using
middle-end types, rather than asking the language.

Actually the whole idea of the type_for_mode langhook seems dubious to
me, but I haven't looked into how it is used.

In any case, since the middle-end does currently expect this to work,
and since two bugs were reported about it, I have patched the Go
frontend to handle vector types in the type_for_mode langhook.
Bootstrapped on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


2010-12-07  Ian Lance Taylor  <iant@google.com>

	PR tree-optimization/46805
	PR tree-optimization/46833
	* go-lang.c (go_langhook_type_for_mode): Handle vector modes.

Comments

Nathan Froyd Dec. 7, 2010, 8:49 p.m. UTC | #1
On Tue, Dec 07, 2010 at 11:32:02AM -0800, Ian Lance Taylor wrote:
> The tree vectorizer calls the type_for_mode langhook with vector modes.
> I'm not sure this makes sense.  If a language doesn't have any vector
> types, then there is nothing sensible that the langhook can return.  It
> seems to me that this should be done entirely in the middle-end, using
> middle-end types, rather than asking the language.
>
>  go_langhook_type_for_mode (enum machine_mode mode, int unsignedp)
>  {
> +  /* Go has no vector types.  Build them here.  FIXME: It does not
> +     make sense for the middle-end to ask the frontend for a type
> +     which the frontend does not support.  However, at least for now
> +     it is required.  See PR 46805.  */
> +  if (VECTOR_MODE_P (mode))
> +    {
> +      tree inner;
> +
> +      inner = go_langhook_type_for_mode (GET_MODE_INNER (mode), unsignedp);
> +      if (inner != NULL_TREE)
> +	return build_vector_type_for_mode (inner, mode);
> +      return NULL_TREE;

It is unfortunate that every language has essentially this same code
(most don't return NULL_TREE, which causes added work in many cases).

-Nathan
diff mbox

Patch

Index: go-lang.c
===================================================================
--- go-lang.c	(revision 167562)
+++ go-lang.c	(working copy)
@@ -285,6 +285,20 @@  go_langhook_type_for_size (unsigned int 
 static tree
 go_langhook_type_for_mode (enum machine_mode mode, int unsignedp)
 {
+  /* Go has no vector types.  Build them here.  FIXME: It does not
+     make sense for the middle-end to ask the frontend for a type
+     which the frontend does not support.  However, at least for now
+     it is required.  See PR 46805.  */
+  if (VECTOR_MODE_P (mode))
+    {
+      tree inner;
+
+      inner = go_langhook_type_for_mode (GET_MODE_INNER (mode), unsignedp);
+      if (inner != NULL_TREE)
+	return build_vector_type_for_mode (inner, mode);
+      return NULL_TREE;
+    }
+
   return go_type_for_mode (mode, unsignedp);
 }