public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-7099] tree-optimization/98855 - fix some vectorizer cost issues
@ 2021-02-04 12:02 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2021-02-04 12:02 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7002a33d1ba81e4577d965fb9daaee146b31faa8

commit r11-7099-g7002a33d1ba81e4577d965fb9daaee146b31faa8
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Feb 4 12:08:47 2021 +0100

    tree-optimization/98855 - fix some vectorizer cost issues
    
    This fixes us not costing vectorized bswap for SLP as well as
    avoiding biasing to the vectorized side when costing single-argument
    PHIs.  Instead we assume coalescing here and cost them with zero cost
    for both the scalar and vectorized code.
    
    This doesn't fix the PR on its own.
    
    2021-02-04  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/98855
            * tree-vect-loop.c (vectorizable_phi): Do not cost
            single-argument PHIs.
            * tree-vect-slp.c (vect_bb_slp_scalar_cost): Likewise.
            * tree-vect-stmts.c (vectorizable_bswap): Also perform
            costing for SLP operation.

Diff:
---
 gcc/tree-vect-loop.c  |  8 ++++++--
 gcc/tree-vect-slp.c   |  7 +++++++
 gcc/tree-vect-stmts.c | 13 ++++++-------
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 200ed27b32e..f1f16e3b1b9 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -7777,8 +7777,12 @@ vectorizable_phi (vec_info *,
 			       "incompatible vector types for invariants\n");
 	    return false;
 	  }
-      record_stmt_cost (cost_vec, SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node),
-			vector_stmt, stmt_info, vectype, 0, vect_body);
+      /* For single-argument PHIs assume coalescing which means zero cost
+	 for the scalar and the vector PHIs.  This avoids artificially
+	 favoring the vector path (but may pessimize it in some cases).  */
+      if (gimple_phi_num_args (as_a <gphi *> (stmt_info->stmt)) > 1)
+	record_stmt_cost (cost_vec, SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node),
+			  vector_stmt, stmt_info, vectype, 0, vect_body);
       STMT_VINFO_TYPE (stmt_info) = phi_info_type;
       return true;
     }
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 10b876ff5ed..2305bbdec3a 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -4297,6 +4297,13 @@ vect_bb_slp_scalar_cost (vec_info *vinfo,
 	}
       else if (vect_nop_conversion_p (orig_stmt_info))
 	continue;
+      /* For single-argument PHIs assume coalescing which means zero cost
+	 for the scalar and the vector PHIs.  This avoids artificially
+	 favoring the vector path (but may pessimize it in some cases).  */
+      else if (is_a <gphi *> (orig_stmt_info->stmt)
+	       && gimple_phi_num_args
+		    (as_a <gphi *> (orig_stmt_info->stmt)) == 1)
+	continue;
       else
 	kind = scalar_stmt;
       record_stmt_cost (cost_vec, 1, kind, orig_stmt_info,
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 5eb7b2d1d6e..0bc1cb1c5b4 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -3002,13 +3002,12 @@ vectorizable_bswap (vec_info *vinfo,
 
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
       DUMP_VECT_SCOPE ("vectorizable_bswap");
-      if (! slp_node)
-	{
-	  record_stmt_cost (cost_vec,
-			    1, vector_stmt, stmt_info, 0, vect_prologue);
-	  record_stmt_cost (cost_vec,
-			    ncopies, vec_perm, stmt_info, 0, vect_body);
-	}
+      record_stmt_cost (cost_vec,
+			1, vector_stmt, stmt_info, 0, vect_prologue);
+      record_stmt_cost (cost_vec,
+			slp_node
+			? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) : ncopies,
+			vec_perm, stmt_info, 0, vect_body);
       return true;
     }


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

only message in thread, other threads:[~2021-02-04 12:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 12:02 [gcc r11-7099] tree-optimization/98855 - fix some vectorizer cost issues Richard Biener

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