public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] tree-optimization/94261 - avoid IL adjustments in SLP analysis
@ 2020-03-27 13:44 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-03-27 13:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4dcc4502f316a7320fe72b62c60af12c77e1c96c

commit 4dcc4502f316a7320fe72b62c60af12c77e1c96c
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Mar 23 13:08:41 2020 +0100

    tree-optimization/94261 - avoid IL adjustments in SLP analysis
    
    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.
    
    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.

Diff:
---
 gcc/ChangeLog       |  8 ++++++++
 gcc/tree-vect-slp.c | 54 ++++++++---------------------------------------------
 2 files changed, 16 insertions(+), 46 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 234afeeb005..8804b0c5249 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+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.
+
 2020-03-23  Tobias Burnus  <tobias@codesourcery.com>
 
 	* doc/install.texi (amdgcn-*-amdhsa): Renamed
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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-27 13:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 13:44 [gcc/devel/c++-modules] tree-optimization/94261 - avoid IL adjustments in SLP analysis Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).