public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Feng Xue OS <fxue@os.amperecomputing.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: Tamar Christina <Tamar.Christina@arm.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 3/6] vect: Set STMT_VINFO_REDUC_DEF for non-live stmt in loop  reduction
Date: Fri, 14 Jun 2024 03:51:36 +0000	[thread overview]
Message-ID: <LV2PR01MB7839E7DE3C81F867C9483F42F7C22@LV2PR01MB7839.prod.exchangelabs.com> (raw)
In-Reply-To: <LV2PR01MB78394944F4EB60BDFC0A7324F7F32@LV2PR01MB7839.prod.exchangelabs.com>

[-- Attachment #1: Type: text/plain, Size: 5208 bytes --]

Updated the patch.

Thanks,
Feng
--

gcc/
        * tree-vect-loop.cc (vectorizable_reduction): Set STMT_VINFO_REDUC_DEF
        for non-live stmt.
        * tree-vect-stmts.cc (vectorizable_condition): Treat the condition
        statement that is pointed by stmt_vec_info of reduction PHI as the
        real "for_reduction" statement.
---
 gcc/tree-vect-loop.cc  |  7 +++++--
 gcc/tree-vect-stmts.cc | 11 ++++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index bbd5d261907..35c50eb72cb 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7665,8 +7665,11 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
            if (STMT_VINFO_LIVE_P (s))
              STMT_VINFO_REDUC_DEF (vect_orig_stmt (s)) = phi_info;
        }
-      else if (STMT_VINFO_LIVE_P (vdef))
-       STMT_VINFO_REDUC_DEF (def) = phi_info;
+
+      /* For lane-reducing operation vectorizable analysis needs the
+        reduction PHI information */
+      STMT_VINFO_REDUC_DEF (def) = phi_info;
+
       gimple_match_op op;
       if (!gimple_extract_op (vdef->stmt, &op))
        {
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index e32d44050e5..dbdb59054e0 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12137,11 +12137,20 @@ vectorizable_condition (vec_info *vinfo,
   vect_reduction_type reduction_type = TREE_CODE_REDUCTION;
   bool for_reduction
     = STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)) != NULL;
+  if (for_reduction)
+    {
+      reduc_info = info_for_reduction (vinfo, stmt_info);
+      if (STMT_VINFO_REDUC_DEF (reduc_info) != vect_orig_stmt (stmt_info))
+       {
+         for_reduction = false;
+         reduc_info = NULL;
+       }
+    }
+
   if (for_reduction)
     {
       if (slp_node && SLP_TREE_LANES (slp_node) > 1)
        return false;
-      reduc_info = info_for_reduction (vinfo, stmt_info);
       reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info);
       reduc_index = STMT_VINFO_REDUC_IDX (stmt_info);
       gcc_assert (reduction_type != EXTRACT_LAST_REDUCTION
--
2.17.1

________________________________________
From: Feng Xue OS <fxue@os.amperecomputing.com>
Sent: Thursday, May 30, 2024 10:51 PM
To: Richard Biener
Cc: Tamar Christina; gcc-patches@gcc.gnu.org
Subject: [PATCH 3/6] vect: Set STMT_VINFO_REDUC_DEF for non-live stmt in loop  reduction

Normally, vectorizable checking on statement in a loop reduction chain does
not use the reduction PHI information. But some special statements might
need it in vectorizable analysis, especially, for multiple lane-reducing
operations support later.

Thanks,
Feng
---
gcc/
        * tree-vect-loop.cc (vectorizable_reduction): Set STMT_VINFO_REDUC_DEF
        for non-live stmt.
        * tree-vect-stmts.cc (vectorizable_condition): Treat the condition
        statement that is pointed by stmt_vec_info of reduction PHI as the
        real "for_reduction" statement.
---
 gcc/tree-vect-loop.cc  |  5 +++--
 gcc/tree-vect-stmts.cc | 11 ++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index aa5f21ccd1a..51627c27f8a 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7632,14 +7632,15 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
         all lanes here - even though we only will vectorize from
         the SLP node with live lane zero the other live lanes also
         need to be identified as part of a reduction to be able
-        to skip code generation for them.  */
+        to skip code generation for them.  For lane-reducing operation
+        vectorizable analysis needs the reduction PHI information.  */
       if (slp_for_stmt_info)
        {
          for (auto s : SLP_TREE_SCALAR_STMTS (slp_for_stmt_info))
            if (STMT_VINFO_LIVE_P (s))
              STMT_VINFO_REDUC_DEF (vect_orig_stmt (s)) = phi_info;
        }
-      else if (STMT_VINFO_LIVE_P (vdef))
+      else
        STMT_VINFO_REDUC_DEF (def) = phi_info;
       gimple_match_op op;
       if (!gimple_extract_op (vdef->stmt, &op))
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 935d80f0e1b..2e0be763abb 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12094,11 +12094,20 @@ vectorizable_condition (vec_info *vinfo,
   vect_reduction_type reduction_type = TREE_CODE_REDUCTION;
   bool for_reduction
     = STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)) != NULL;
+  if (for_reduction)
+    {
+      reduc_info = info_for_reduction (vinfo, stmt_info);
+      if (STMT_VINFO_REDUC_DEF (reduc_info) != vect_orig_stmt (stmt_info))
+       {
+         for_reduction = false;
+         reduc_info = NULL;
+       }
+    }
+
   if (for_reduction)
     {
       if (slp_node)
        return false;
-      reduc_info = info_for_reduction (vinfo, stmt_info);
       reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info);
       reduc_index = STMT_VINFO_REDUC_IDX (stmt_info);
       gcc_assert (reduction_type != EXTRACT_LAST_REDUCTION
--
2.17.1

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-vect-Set-STMT_VINFO_REDUC_DEF-for-non-live-stmt-in-l.patch --]
[-- Type: text/x-patch; name="0001-vect-Set-STMT_VINFO_REDUC_DEF-for-non-live-stmt-in-l.patch", Size: 2541 bytes --]

From 2270584f95637e88cf05a9c3f8bfc77c37eab979 Mon Sep 17 00:00:00 2001
From: Feng Xue <fxue@os.amperecomputing.com>
Date: Wed, 29 May 2024 14:41:34 +0800
Subject: [PATCH 1/3] vect: Set STMT_VINFO_REDUC_DEF for non-live stmt in loop
 reduction

Normally, vectorizable checking on statement in a loop reduction chain does
not use the reduction PHI information. But some special statements might
need it in vectorizable analysis, especially, for multiple lane-reducing
operations support later.

2024-05-29 Feng Xue <fxue@os.amperecomputing.com>

gcc/
	* tree-vect-loop.cc (vectorizable_reduction): Set STMT_VINFO_REDUC_DEF
	for non-live stmt.
	* tree-vect-stmts.cc (vectorizable_condition): Treat the condition
    	statement that is pointed by stmt_vec_info of reduction PHI as the
    	real "for_reduction" statement.
---
 gcc/tree-vect-loop.cc  |  7 +++++--
 gcc/tree-vect-stmts.cc | 11 ++++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index bbd5d261907..35c50eb72cb 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7665,8 +7665,11 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
 	    if (STMT_VINFO_LIVE_P (s))
 	      STMT_VINFO_REDUC_DEF (vect_orig_stmt (s)) = phi_info;
 	}
-      else if (STMT_VINFO_LIVE_P (vdef))
-	STMT_VINFO_REDUC_DEF (def) = phi_info;
+
+      /* For lane-reducing operation vectorizable analysis needs the
+	 reduction PHI information */
+      STMT_VINFO_REDUC_DEF (def) = phi_info;
+
       gimple_match_op op;
       if (!gimple_extract_op (vdef->stmt, &op))
 	{
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index e32d44050e5..dbdb59054e0 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -12137,11 +12137,20 @@ vectorizable_condition (vec_info *vinfo,
   vect_reduction_type reduction_type = TREE_CODE_REDUCTION;
   bool for_reduction
     = STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)) != NULL;
+  if (for_reduction)
+    {
+      reduc_info = info_for_reduction (vinfo, stmt_info);
+      if (STMT_VINFO_REDUC_DEF (reduc_info) != vect_orig_stmt (stmt_info))
+	{
+	  for_reduction = false;
+	  reduc_info = NULL;
+	}
+    }
+
   if (for_reduction)
     {
       if (slp_node && SLP_TREE_LANES (slp_node) > 1)
 	return false;
-      reduc_info = info_for_reduction (vinfo, stmt_info);
       reduction_type = STMT_VINFO_REDUC_TYPE (reduc_info);
       reduc_index = STMT_VINFO_REDUC_IDX (stmt_info);
       gcc_assert (reduction_type != EXTRACT_LAST_REDUCTION
-- 
2.17.1


      reply	other threads:[~2024-06-14  3:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-30 14:51 Feng Xue OS
2024-06-14  3:51 ` Feng Xue OS [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=LV2PR01MB7839E7DE3C81F867C9483F42F7C22@LV2PR01MB7839.prod.exchangelabs.com \
    --to=fxue@os.amperecomputing.com \
    --cc=Tamar.Christina@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).