public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/avieira/heads/BBSLP)] permute changes
@ 2020-08-04  9:09 Andre Simoes Dias Vieira
  0 siblings, 0 replies; only message in thread
From: Andre Simoes Dias Vieira @ 2020-08-04  9:09 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bc27500011df01258ef5d22665bb183b29ea4c34

commit bc27500011df01258ef5d22665bb183b29ea4c34
Author: Andre Vieira <andre.simoesdiasvieira@arm.com>
Date:   Mon Aug 3 15:10:32 2020 +0100

    permute changes

Diff:
---
 gcc/tree-vect-slp.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 65a49a05ab0..6a4b5c585d1 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1156,14 +1156,16 @@ static slp_tree
 vect_build_slp_tree_2 (vec_info *vinfo,
 		       vec<stmt_vec_info> stmts, unsigned int group_size,
 		       poly_uint64 *max_nunits,
-		       bool *matches, unsigned *npermutes, unsigned *tree_size,
+		       bool *matches, unsigned *npermutes,
+		       bool parent_can_permute, unsigned *tree_size,
 		       scalar_stmts_to_slp_tree_map_t *bst_map);
 
 static slp_tree
 vect_build_slp_tree (vec_info *vinfo,
 		     vec<stmt_vec_info> stmts, unsigned int group_size,
 		     poly_uint64 *max_nunits,
-		     bool *matches, unsigned *npermutes, unsigned *tree_size,
+		     bool *matches, unsigned *npermutes,
+		     bool parent_can_permute, unsigned *tree_size,
 		     scalar_stmts_to_slp_tree_map_t *bst_map)
 {
   if (slp_tree *leader = bst_map->get (stmts))
@@ -1180,8 +1182,8 @@ vect_build_slp_tree (vec_info *vinfo,
     }
   poly_uint64 this_max_nunits = 1;
   slp_tree res = vect_build_slp_tree_2 (vinfo, stmts, group_size,
-					&this_max_nunits,
-					matches, npermutes, tree_size, bst_map);
+					&this_max_nunits, matches, npermutes,
+					parent_can_permute, tree_size, bst_map);
   if (res)
     {
       res->max_nunits = this_max_nunits;
@@ -1204,7 +1206,8 @@ static slp_tree
 vect_build_slp_tree_2 (vec_info *vinfo,
 		       vec<stmt_vec_info> stmts, unsigned int group_size,
 		       poly_uint64 *max_nunits,
-		       bool *matches, unsigned *npermutes, unsigned *tree_size,
+		       bool *matches, unsigned *npermutes,
+		       bool parent_can_permute, unsigned *tree_size,
 		       scalar_stmts_to_slp_tree_map_t *bst_map)
 {
   unsigned nops, i, this_tree_size = 0;
@@ -1354,9 +1357,21 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 	  continue;
 	}
 
+      bool we_can_permute
+	= (i == 0
+	   /* ???  For COND_EXPRs we can swap the comparison operands
+	      as well as the arms under some constraints.  */
+	   && nops == 2
+	   && oprnds_info[1]->first_dt == vect_internal_def
+	   && is_gimple_assign (stmt_info->stmt)
+	   /* Swapping operands for reductions breaks assumptions later on.  */
+	   && STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def
+	   && STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def);
+
       if ((child = vect_build_slp_tree (vinfo, oprnd_info->def_stmts,
 					group_size, &this_max_nunits,
 					matches, npermutes,
+					parent_can_permute || we_can_permute,
 					&this_tree_size, bst_map)) != NULL)
 	{
 	  oprnd_info->def_stmts = vNULL;
@@ -1368,15 +1383,10 @@ vect_build_slp_tree_2 (vec_info *vinfo,
          simply treat nodes we fail to build as externally defined
 	 (and thus build vectors from the scalar defs).
 	 The cost model will reject outright expensive cases.
-	 ???  This doesn't treat cases where permutation ultimatively
-	 fails (or we don't try permutation below).  Ideally we'd
-	 even compute a permutation that will end up with the maximum
-	 SLP tree size...  */
+	 ???  We delay the build from scalars when the parent can still
+	 try permutations, still this may not handle all cases.  */
       if (is_a <bb_vec_info> (vinfo)
 	  && !matches[0]
-	  /* ???  Rejecting patterns this way doesn't work.  We'd have to
-	     do extra work to cancel the pattern so the uses see the
-	     scalar version.  */
 	  && !is_pattern_stmt_p (stmt_info)
 	  && !oprnd_info->any_pattern)
 	{
@@ -1456,6 +1466,7 @@ vect_build_slp_tree_2 (vec_info *vinfo,
 	  if ((child = vect_build_slp_tree (vinfo, oprnd_info->def_stmts,
 					    group_size, &this_max_nunits,
 					    tem, npermutes,
+					    parent_can_permute,
 					    &this_tree_size, bst_map)) != NULL)
 	    {
 	      oprnd_info->def_stmts = vNULL;
@@ -2158,7 +2169,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
   poly_uint64 max_nunits = nunits;
   unsigned tree_size = 0;
   node = vect_build_slp_tree (vinfo, scalar_stmts, group_size,
-			      &max_nunits, matches, &npermutes,
+			      &max_nunits, matches, &npermutes, false,
 			      &tree_size, bst_map);
   if (node != NULL)
     {


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

only message in thread, other threads:[~2020-08-04  9:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04  9:09 [gcc(refs/users/avieira/heads/BBSLP)] permute changes Andre Simoes Dias Vieira

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).