This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] make vector CONSTRUCTOR with TREE_CONSTANT true, min invariant


We should treat vector CONSTRUCTOR with TREE_CONSTANT set as min
invariant since we no longer look into them to gimplify them and they
are constants so we should be able to treat them as such now.  This
actually improves the code generation for the following C++ code (as the
C++ front-end does not produce VECTOR_CSTs):
typedef __attribute((vector_size(16) )) float vec_float4;
static const vec_float4 c_twos   = { 2.0f, 2.0f, 2.0f, 2.0f  };
vec_float4 g(void)
{
  return c_twos;
}

We no longer get a load from c_twos and we can place if need be the
constant in the constant pool if a target needs to.

For the SPU target, we get now with this patch on the C++ code (we
already get this with the C front-end):
g:
        ilhu    $3,16384
        bi      $lr

OK?  Bootstrapped and tested on i686-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

	* tree-gimple.c (is_gimple_min_invariant): Treat constant vector
	CONSTRUCTORs as min invariants.
Index: tree-gimple.c
===================================================================
--- tree-gimple.c	(revision 119958)
+++ tree-gimple.c	(working copy)
@@ -183,6 +183,11 @@ is_gimple_min_invariant (tree t)
     case VECTOR_CST:
       return true;
 
+    /* Vector constructors as constant is gimple invariant.  */
+    case CONSTRUCTOR:
+      if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == VECTOR_TYPE)
+	return TREE_CONSTANT (t);
+
     default:
       return false;
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]