public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2139] vect: Remove always-true condition
@ 2021-07-08 11:58 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2021-07-08 11:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2e9ef3929b0305235b968c431c8d7fec92885101

commit r12-2139-g2e9ef3929b0305235b968c431c8d7fec92885101
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Thu Jul 8 12:58:13 2021 +0100

    vect: Remove always-true condition
    
    vectorizable_reduction had code guarded by:
    
      if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
          || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def)
    
    But that's always true after:
    
      if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def
          && STMT_VINFO_DEF_TYPE (stmt_info) != vect_double_reduction_def
          && STMT_VINFO_DEF_TYPE (stmt_info) != vect_nested_cycle)
        return false;
    
      if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_nested_cycle)
        {
          …
          return true;
        }
    
    (I wasn't sure at first how the empty “else” for the first “if” above
    was supposed to work.)
    
    gcc/
            * tree-vect-loop.c (vectorizable_reduction): Remove always-true
            if condition.

Diff:
---
 gcc/tree-vect-loop.c | 50 ++++++++++++++++++++++++--------------------------
 1 file changed, 24 insertions(+), 26 deletions(-)

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 51a46a6d852..bc523d151c6 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -6516,33 +6516,31 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
 
   stmt_vec_info orig_stmt_of_analysis = stmt_info;
   stmt_vec_info phi_info = stmt_info;
-  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def
-      || STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def)
+  if (!is_a <gphi *> (stmt_info->stmt))
     {
-      if (!is_a <gphi *> (stmt_info->stmt))
-	{
-	  STMT_VINFO_TYPE (stmt_info) = reduc_vec_info_type;
-	  return true;
-	}
-      if (slp_node)
-	{
-	  slp_node_instance->reduc_phis = slp_node;
-	  /* ???  We're leaving slp_node to point to the PHIs, we only
-	     need it to get at the number of vector stmts which wasn't
-	     yet initialized for the instance root.  */
-	}
-      if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
-	stmt_info = vect_stmt_to_vectorize (STMT_VINFO_REDUC_DEF (stmt_info));
-      else /* STMT_VINFO_DEF_TYPE (stmt_info) == vect_double_reduction_def */
-	{
-	  use_operand_p use_p;
-	  gimple *use_stmt;
-	  bool res = single_imm_use (gimple_phi_result (stmt_info->stmt),
-				     &use_p, &use_stmt);
-	  gcc_assert (res);
-	  phi_info = loop_vinfo->lookup_stmt (use_stmt);
-	  stmt_info = vect_stmt_to_vectorize (STMT_VINFO_REDUC_DEF (phi_info));
-	}
+      STMT_VINFO_TYPE (stmt_info) = reduc_vec_info_type;
+      return true;
+    }
+  if (slp_node)
+    {
+      slp_node_instance->reduc_phis = slp_node;
+      /* ???  We're leaving slp_node to point to the PHIs, we only
+	 need it to get at the number of vector stmts which wasn't
+	 yet initialized for the instance root.  */
+    }
+  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
+    stmt_info = vect_stmt_to_vectorize (STMT_VINFO_REDUC_DEF (stmt_info));
+  else
+    {
+      gcc_assert (STMT_VINFO_DEF_TYPE (stmt_info)
+		  == vect_double_reduction_def);
+      use_operand_p use_p;
+      gimple *use_stmt;
+      bool res = single_imm_use (gimple_phi_result (stmt_info->stmt),
+				 &use_p, &use_stmt);
+      gcc_assert (res);
+      phi_info = loop_vinfo->lookup_stmt (use_stmt);
+      stmt_info = vect_stmt_to_vectorize (STMT_VINFO_REDUC_DEF (phi_info));
     }
 
   /* PHIs should not participate in patterns.  */


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

only message in thread, other threads:[~2021-07-08 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 11:58 [gcc r12-2139] vect: Remove always-true condition Richard Sandiford

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