[2/5] Make vectorizable_operation punt early on codes it doesn't handle

Message ID mptimn3yoqt.fsf@arm.com
State New
Headers show
Series
  • Don't defer vector type choice for bools (PR 92596)
Related show

Commit Message

Richard Sandiford Nov. 29, 2019, 10:13 a.m.
vectorizable_operation returned false for codes that are handled by
vectorizable_shift, but only after it had already done a lot of work.
Checking earlier should be more efficient and avoid polluting the logs
with duplicate info.

Also, there was no such early-out for comparisons or COND_EXPRs.
Fixing that avoids a false scan-tree-dump hit with a later patch.


2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vect-stmts.c (vectorizable_operation): Punt early
	on codes that are handled elsewhere.

Comments

Richard Biener Nov. 29, 2019, 10:25 a.m. | #1
On Fri, Nov 29, 2019 at 11:13 AM Richard Sandiford
<richard.sandiford@arm.com> wrote:
>

> vectorizable_operation returned false for codes that are handled by

> vectorizable_shift, but only after it had already done a lot of work.

> Checking earlier should be more efficient and avoid polluting the logs

> with duplicate info.

>

> Also, there was no such early-out for comparisons or COND_EXPRs.

> Fixing that avoids a false scan-tree-dump hit with a later patch.


OK.

>

> 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

>

> gcc/

>         * tree-vect-stmts.c (vectorizable_operation): Punt early

>         on codes that are handled elsewhere.

>

> Index: gcc/tree-vect-stmts.c

> ===================================================================

> --- gcc/tree-vect-stmts.c       2019-11-29 08:28:12.015121876 +0000

> +++ gcc/tree-vect-stmts.c       2019-11-29 09:11:24.553108756 +0000

> @@ -5999,6 +5999,21 @@ vectorizable_operation (stmt_vec_info st

>

>    orig_code = code = gimple_assign_rhs_code (stmt);

>

> +  /* Shifts are handled in vectorizable_shift.  */

> +  if (code == LSHIFT_EXPR

> +      || code == RSHIFT_EXPR

> +      || code == LROTATE_EXPR

> +      || code == RROTATE_EXPR)

> +   return false;

> +

> +  /* Comparisons are handled in vectorizable_comparison.  */

> +  if (TREE_CODE_CLASS (code) == tcc_comparison)

> +    return false;

> +

> +  /* Conditions are handled in vectorizable_condition.  */

> +  if (code == COND_EXPR)

> +    return false;

> +

>    /* For pointer addition and subtraction, we should use the normal

>       plus and minus for the vector operation.  */

>    if (code == POINTER_PLUS_EXPR)

> @@ -6123,11 +6138,6 @@ vectorizable_operation (stmt_vec_info st

>

>    gcc_assert (ncopies >= 1);

>

> -  /* Shifts are handled in vectorizable_shift ().  */

> -  if (code == LSHIFT_EXPR || code == RSHIFT_EXPR || code == LROTATE_EXPR

> -      || code == RROTATE_EXPR)

> -   return false;

> -

>    /* Supportable by target?  */

>

>    vec_mode = TYPE_MODE (vectype);

Patch

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c	2019-11-29 08:28:12.015121876 +0000
+++ gcc/tree-vect-stmts.c	2019-11-29 09:11:24.553108756 +0000
@@ -5999,6 +5999,21 @@  vectorizable_operation (stmt_vec_info st
 
   orig_code = code = gimple_assign_rhs_code (stmt);
 
+  /* Shifts are handled in vectorizable_shift.  */
+  if (code == LSHIFT_EXPR
+      || code == RSHIFT_EXPR
+      || code == LROTATE_EXPR
+      || code == RROTATE_EXPR)
+   return false;
+
+  /* Comparisons are handled in vectorizable_comparison.  */
+  if (TREE_CODE_CLASS (code) == tcc_comparison)
+    return false;
+
+  /* Conditions are handled in vectorizable_condition.  */
+  if (code == COND_EXPR)
+    return false;
+
   /* For pointer addition and subtraction, we should use the normal
      plus and minus for the vector operation.  */
   if (code == POINTER_PLUS_EXPR)
@@ -6123,11 +6138,6 @@  vectorizable_operation (stmt_vec_info st
 
   gcc_assert (ncopies >= 1);
 
-  /* Shifts are handled in vectorizable_shift ().  */
-  if (code == LSHIFT_EXPR || code == RSHIFT_EXPR || code == LROTATE_EXPR
-      || code == RROTATE_EXPR)
-   return false;
-
   /* Supportable by target?  */
 
   vec_mode = TYPE_MODE (vectype);