diff mbox series

tree-optimization/94261 - avoid IL adjustments in SLP analysis

Message ID nycvar.YFH.7.76.2003231515550.5137@zhemvz.fhfr.qr
State New
Headers show
Series tree-optimization/94261 - avoid IL adjustments in SLP analysis | expand

Commit Message

Richard Biener March 23, 2020, 2:16 p.m. UTC
The remaining IL adjustment done by SLP analysis turns out harmful
since we share them in the now multiple analyses states.  It turns
out we do not actually need those apart from the case where we
reorg scalar stmts during re-arrangement when optimizing load
permutations in SLP reductions.  But that isn't needed either now
since we only need to permute non-isomorphic parts which now
reside in separate SLP nodes who are all leafs.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
CPU2006 was OK with -Ofast -march=haswell.

Richard.

2020-03-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/94261
	* tree-vect-slp.c (vect_get_and_check_slp_defs): Remove
	IL operand swapping code.
	(vect_slp_rearrange_stmts): Do not arrange isomorphic
	nodes that would need operation code adjustments.
---
 gcc/tree-vect-slp.c | 54 ++++++++---------------------------------------------
 1 file changed, 8 insertions(+), 46 deletions(-)
diff mbox series

Patch

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index e43d03b43de..f6331eeea86 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -562,52 +562,6 @@  again:
   /* Swap operands.  */
   if (swapped)
     {
-      if (first_op_cond)
-	{
-	  /* If there are already uses of this stmt in a SLP instance then
-	     we've committed to the operand order and can't swap it.  */
-	  if (STMT_VINFO_NUM_SLP_USES (stmt_info) != 0)
-	    {
-	      if (dump_enabled_p ())
-		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-				 "Build SLP failed: cannot swap operands of "
-				 "shared stmt %G", stmt_info->stmt);
-	      return -1;
-	    }
-
-	  /* To get rid of this swapping we have to move the stmt code
-	     to the SLP tree as well (and gather it here per stmt).  */
-	  gassign *stmt = as_a <gassign *> (stmt_info->stmt);
-	  tree cond = gimple_assign_rhs1 (stmt);
-	  enum tree_code code = TREE_CODE (cond);
-
-	  /* Swap.  */
-	  if (*swap == 1)
-	    {
-	      swap_ssa_operands (stmt, &TREE_OPERAND (cond, 0),
-				 &TREE_OPERAND (cond, 1));
-	      TREE_SET_CODE (cond, swap_tree_comparison (code));
-	    }
-	  /* Invert.  */
-	  else
-	    {
-	      swap_ssa_operands (stmt, gimple_assign_rhs2_ptr (stmt),
-				 gimple_assign_rhs3_ptr (stmt));
-	      if (STMT_VINFO_REDUC_IDX (stmt_info) == 1)
-		STMT_VINFO_REDUC_IDX (stmt_info) = 2;
-	      else if (STMT_VINFO_REDUC_IDX (stmt_info) == 2)
-		STMT_VINFO_REDUC_IDX (stmt_info) = 1;
-	      bool honor_nans = HONOR_NANS (TREE_OPERAND (cond, 0));
-	      code = invert_tree_comparison (TREE_CODE (cond), honor_nans);
-	      gcc_assert (code != ERROR_MARK);
-	      TREE_SET_CODE (cond, code);
-	    }
-	}
-      else
-	{
-	  /* Commutative ops need not reflect swapping, ops are in
-	     the SLP tree.  */
-	}
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_NOTE, vect_location,
 			 "swapped operands to match def types in %G",
@@ -1815,6 +1769,14 @@  vect_slp_rearrange_stmts (slp_tree node, unsigned int group_size,
   if (SLP_TREE_SCALAR_STMTS (node).exists ())
     {
       gcc_assert (group_size == SLP_TREE_SCALAR_STMTS (node).length ());
+      /* ???  Computation nodes are isomorphic and need no rearrangement.
+	 This is a quick hack to cover those where rearrangement breaks
+	 semantics because only the first stmt is guaranteed to have the
+	 correct operation code due to others being swapped or inverted.  */
+      stmt_vec_info first = SLP_TREE_SCALAR_STMTS (node)[0];
+      if (is_gimple_assign (first->stmt)
+	  && gimple_assign_rhs_code (first->stmt) == COND_EXPR)
+	return;
       vec<stmt_vec_info> tmp_stmts;
       tmp_stmts.create (group_size);
       tmp_stmts.quick_grow (group_size);