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] Don't optimize { x, x + 1, x + 2, x + 3 } ctors if there is no vector addition optab (PR middle-end/59273)


Hi!

Uros has reported my optimize_vector_constructor optimization causes
problems on Alpha which for some vector modes supports only moves, but not
arithmetics.  The following patch fixed that in a cross compiler,
and has been bootstrapped/regtested on x86_64-linux and i686-linux.

Ok for trunk?

2013-11-26  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/59273
	* tree-vect-generic.c (optimize_vector_constructor): Don't optimize
	if there isn't optab handler for the corresponding vector PLUS_EXPR.

--- gcc/tree-vect-generic.c.jj	2013-11-22 21:03:16.000000000 +0100
+++ gcc/tree-vect-generic.c	2013-11-26 08:53:11.117052615 +0100
@@ -1015,9 +1015,14 @@ optimize_vector_constructor (gimple_stmt
   tree *cst;
   gimple g;
   tree base = NULL_TREE;
+  optab op;
 
   if (nelts <= 2 || CONSTRUCTOR_NELTS (rhs) != nelts)
     return;
+  op = optab_for_tree_code (PLUS_EXPR, type, optab_default);
+  if (op == unknown_optab
+      || optab_handler (op, TYPE_MODE (type)) == CODE_FOR_nothing)
+    return;
   FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (rhs), i, elt)
     if (TREE_CODE (elt->value) != SSA_NAME
 	|| TREE_CODE (TREE_TYPE (elt->value)) == VECTOR_TYPE)

	Jakub


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