diff mbox

Fix PR80457

Message ID 507725db-45cf-e734-095d-2225087c53a8@linux.vnet.ibm.com
State New
Headers show

Commit Message

Bill Schmidt April 18, 2017, 10:38 p.m. UTC
Hi,

While investigating a performance issue, I happened to notice that vectorized
COND_EXPRs were not contributing to the vectorizer cost model.  This patch
addresses that.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu.  Is this ok for
trunk, or should it wait for GCC 8?

Thanks,
Bill


[gcc]

2017-04-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/80457
	* tree-vect-stmts.c (vectorizable_condition): Update the cost
	model when vectorizing a COND_EXPR.

[gcc/testsuite]

2017-04-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	PR tree-optimization/80457
	* gcc.target/powerpc/pr78604.c: Verify that vectorized COND_EXPRs
	call vect_model_simple_cost.

Comments

Richard Biener April 20, 2017, 7:46 a.m. UTC | #1
On Wed, Apr 19, 2017 at 12:38 AM, Bill Schmidt
<wschmidt@linux.vnet.ibm.com> wrote:
> Hi,
>
> While investigating a performance issue, I happened to notice that vectorized
> COND_EXPRs were not contributing to the vectorizer cost model.  This patch
> addresses that.
>
> Bootstrapped and tested on powerpc64le-unknown-linux-gnu.  Is this ok for
> trunk, or should it wait for GCC 8?

Ok for GCC 8, this is not a regression.

Thanks,
Richard.

> Thanks,
> Bill
>
>
> [gcc]
>
> 2017-04-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>         PR tree-optimization/80457
>         * tree-vect-stmts.c (vectorizable_condition): Update the cost
>         model when vectorizing a COND_EXPR.
>
> [gcc/testsuite]
>
> 2017-04-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
>
>         PR tree-optimization/80457
>         * gcc.target/powerpc/pr78604.c: Verify that vectorized COND_EXPRs
>         call vect_model_simple_cost.
>
>
> Index: gcc/testsuite/gcc.target/powerpc/pr78604.c
> ===================================================================
> --- gcc/testsuite/gcc.target/powerpc/pr78604.c  (revision 246948)
> +++ gcc/testsuite/gcc.target/powerpc/pr78604.c  (working copy)
> @@ -2,7 +2,7 @@
>  /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
>  /* { dg-require-effective-target powerpc_p8vector_ok } */
>  /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
> -/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize" } */
> +/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fdump-tree-vect-details" } */
>
>  #ifndef SIZE
>  #define SIZE 1024
> @@ -110,3 +110,4 @@ uns_gte (UNS_TYPE val1, UNS_TYPE val2)
>  /* { dg-final { scan-assembler-times {\mvcmpgtsd\M} 4 } } */
>  /* { dg-final { scan-assembler-times {\mvcmpgtud\M} 4 } } */
>  /* { dg-final { scan-assembler-not   {\mvcmpequd\M} } } */
> +/* { dg-final { scan-tree-dump-times "vect_model_simple_cost" 8 "vect" } } */
> Index: gcc/tree-vect-stmts.c
> ===================================================================
> --- gcc/tree-vect-stmts.c       (revision 246948)
> +++ gcc/tree-vect-stmts.c       (working copy)
> @@ -7746,7 +7746,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_
>    tree vec_compare;
>    tree new_temp;
>    loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
> -  enum vect_def_type dt, dts[4];
> +  enum vect_def_type dt[2], dts[4];
>    int ncopies;
>    enum tree_code code, cond_code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR;
>    stmt_vec_info prev_stmt_info = NULL;
> @@ -7813,10 +7813,10 @@ vectorizable_condition (gimple *stmt, gimple_stmt_
>      return false;
>
>    gimple *def_stmt;
> -  if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dt,
> +  if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dt[0],
>                            &vectype1))
>      return false;
> -  if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dt,
> +  if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dt[1],
>                            &vectype2))
>      return false;
>
> @@ -7900,8 +7900,12 @@ vectorizable_condition (gimple *stmt, gimple_stmt_
>                 return false;
>             }
>         }
> -      return expand_vec_cond_expr_p (vectype, comp_vectype,
> -                                    cond_code);
> +      if (expand_vec_cond_expr_p (vectype, comp_vectype, cond_code))
> +       {
> +         vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL);
> +         return true;
> +       }
> +      return false;
>      }
>
>    /* Transform.  */
>
diff mbox

Patch

Index: gcc/testsuite/gcc.target/powerpc/pr78604.c
===================================================================
--- gcc/testsuite/gcc.target/powerpc/pr78604.c	(revision 246948)
+++ gcc/testsuite/gcc.target/powerpc/pr78604.c	(working copy)
@@ -2,7 +2,7 @@ 
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize" } */
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fdump-tree-vect-details" } */
 
 #ifndef SIZE
 #define SIZE 1024
@@ -110,3 +110,4 @@  uns_gte (UNS_TYPE val1, UNS_TYPE val2)
 /* { dg-final { scan-assembler-times {\mvcmpgtsd\M} 4 } } */
 /* { dg-final { scan-assembler-times {\mvcmpgtud\M} 4 } } */
 /* { dg-final { scan-assembler-not   {\mvcmpequd\M} } } */
+/* { dg-final { scan-tree-dump-times "vect_model_simple_cost" 8 "vect" } } */
Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	(revision 246948)
+++ gcc/tree-vect-stmts.c	(working copy)
@@ -7746,7 +7746,7 @@  vectorizable_condition (gimple *stmt, gimple_stmt_
   tree vec_compare;
   tree new_temp;
   loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
-  enum vect_def_type dt, dts[4];
+  enum vect_def_type dt[2], dts[4];
   int ncopies;
   enum tree_code code, cond_code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR;
   stmt_vec_info prev_stmt_info = NULL;
@@ -7813,10 +7813,10 @@  vectorizable_condition (gimple *stmt, gimple_stmt_
     return false;
 
   gimple *def_stmt;
-  if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dt,
+  if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dt[0],
 			   &vectype1))
     return false;
-  if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dt,
+  if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dt[1],
 			   &vectype2))
     return false;
 
@@ -7900,8 +7900,12 @@  vectorizable_condition (gimple *stmt, gimple_stmt_
 		return false;
 	    }
 	}
-      return expand_vec_cond_expr_p (vectype, comp_vectype,
-				     cond_code);
+      if (expand_vec_cond_expr_p (vectype, comp_vectype, cond_code))
+	{
+	  vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL);
+	  return true;
+	}
+      return false;
     }
 
   /* Transform.  */