diff mbox

Fix up VEC_INTERLEAVE_*_EXPR folding and expansion for big endian (PR tree-optimization/51074)

Message ID 4EDEACF7.4010904@redhat.com
State New
Headers show

Commit Message

Richard Henderson Dec. 7, 2011, 12:01 a.m. UTC
On 12/01/2011 08:01 AM, Jakub Jelinek wrote:
> Here is the vectorizer part (untested so far) + some small i386 tweaks.
> This patch as is regresses code quality for powerpc/ia64/sparc/mips
> (I don't think spu has vec_interleave* patterns in *.md).
> 
> If it works out, I guess we could also zap VEC_EXTRACT_{EVEN,ODD}_EXPR
> similarly.
> 
> 2011-12-01  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* tree.def (VEC_INTERLEAVE_HIGH_EXPR, VEC_INTERLEAVE_LOW_EXPR): Remove.
> 	* gimple-pretty-print.c (dump_binary_rhs): Don't handle
> 	VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR.
> 	* expr.c (expand_expr_real_2): Likewise.
> 	* tree-cfg.c (verify_gimple_assign_binary): Likewise.
> 	* cfgexpand.c (expand_debug_expr): Likewise.
> 	* tree-inline.c (estimate_operator_cost): Likewise.
> 	* tree-pretty-print.c (dump_generic_node): Likewise.
> 	* tree-vect-generic.c (expand_vector_operations_1): Likewise.
> 	* fold-const.c (fold_binary_loc): Likewise.
> 	* doc/generic.texi (VEC_INTERLEAVE_HIGH_EXPR,
> 	VEC_INTERLEAVE_LOW_EXPR): Remove documentation.
> 	* optabs.c (optab_for_tree_code): Don't handle
> 	VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR.
> 	(expand_binop, init_optabs): Remove vec_interleave_high_optab
> 	and vec_interleave_low_optab.
> 	* genopinit.c (optabs): Likewise.
> 	* optabs.h (OTI_vec_interleave_high, OTI_vec_interleave_low): Remove.
> 	(vec_interleave_high_optab, vec_interleave_low_optab): Remove.
> 	* doc/md.texi (vec_interleave_high, vec_interleave_low): Remove
> 	documentation.
> 	* tree-vect-stmts.c (gen_perm_mask): Renamed to...
> 	(vect_gen_perm_mask): ... this.  No longer static.
> 	(perm_mask_for_reverse, vectorizable_load): Adjust callers.
> 	* tree-vectorizer.h (vect_gen_perm_mask): New prototype.
> 	* tree-vect-data-refs.c (vect_strided_store_supported): Don't try
> 	VEC_INTERLEAVE_*_EXPR, use can_vec_perm_p instead of
> 	can_vec_perm_for_code_p.
> 	(vect_permute_store_chain): Generate VEC_PERM_EXPR with interleaving
> 	masks instead of VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR.
> 	* config/i386/i386.c (expand_vec_perm_interleave2): If
> 	expand_vec_perm_interleave3 would handle it, return false.
> 	(expand_vec_perm_broadcast_1): Don't use vec_interleave_*_optab.

Looks nearly ok.  I had to apply the following for a signed/unsigned bootstrap werror.

I'm currently testing patches for altivec and ia64 to implement vec_perm_const, recognizing the few patterns that we need.  I'm not 100% sure how to test the ppc paired-single support.  I'll certainly get to the other targets asap.


r~
diff mbox

Patch

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index b9c4cb0..23813de 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -3902,7 +3902,7 @@  vect_permute_store_chain (VEC(tree,heap) *dr_chain,
   gimple perm_stmt;
   tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt));
   tree perm_mask_low, perm_mask_high;
-  int i;
+  unsigned int i, n;
   unsigned int j, nelt = GET_MODE_NUNITS (TYPE_MODE (vectype));
   unsigned char *sel = XALLOCAVEC (unsigned char, nelt);
 
@@ -3910,7 +3910,7 @@  vect_permute_store_chain (VEC(tree,heap) *dr_chain,
 
   *result_chain = VEC_copy (tree, heap, dr_chain);
 
-  for (i = 0; i < nelt / 2; i++)
+  for (i = 0, n = nelt / 2; i < n; i++)
     {
       sel[i * 2] = i;
       sel[i * 2 + 1] = i + nelt;
@@ -3920,7 +3920,7 @@  vect_permute_store_chain (VEC(tree,heap) *dr_chain,
     sel[i] += nelt / 2;
   perm_mask_low = vect_gen_perm_mask (vectype, sel);
 
-  for (i = 0; i < exact_log2 (length); i++)
+  for (i = 0, n = exact_log2 (length); i < n; i++)
     {
       for (j = 0; j < length/2; j++)
 	{