[RFC,1/5] vect: Fix single_imm_use in tree_vect_patterns

Message ID LV2PR01MB78398755C9C2FFCC5CE994E8F7AF2@LV2PR01MB7839.prod.exchangelabs.com
State New
Headers
Series [RFC,1/5] vect: Fix single_imm_use in tree_vect_patterns |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Feng Xue OS July 21, 2024, 9:14 a.m. UTC
  The work for RFC (https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657860.html)
involves not a little code change, so I have to separate it into several batches
of patchset. This and the following patches constitute the first batch.

Since pattern statement coexists with normal statements in a way that it is
not linked into function body, we should not invoke utility procedures that
depends on def/use graph on pattern statement, such as counting uses of a
pseudo value defined by a pattern statement. This patch is to fix a bug of
this type in vect pattern formation.

Thanks,
Feng
---
gcc/
	* tree-vect-patterns.cc (vect_recog_bitfield_ref_pattern): Only call
	single_imm_use if statement is not generated by pattern recognition.
---
 gcc/tree-vect-patterns.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Richard Biener July 26, 2024, 12:37 p.m. UTC | #1
On Sun, Jul 21, 2024 at 11:15 AM Feng Xue OS
<fxue@os.amperecomputing.com> wrote:
>
> The work for RFC (https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657860.html)
> involves not a little code change, so I have to separate it into several batches
> of patchset. This and the following patches constitute the first batch.
>
> Since pattern statement coexists with normal statements in a way that it is
> not linked into function body, we should not invoke utility procedures that
> depends on def/use graph on pattern statement, such as counting uses of a
> pseudo value defined by a pattern statement. This patch is to fix a bug of
> this type in vect pattern formation.
>
> Thanks,
> Feng
> ---
> gcc/
>         * tree-vect-patterns.cc (vect_recog_bitfield_ref_pattern): Only call
>         single_imm_use if statement is not generated by pattern recognition.
> ---
>  gcc/tree-vect-patterns.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
> index 4570c25b664..ca8809e7cfd 100644
> --- a/gcc/tree-vect-patterns.cc
> +++ b/gcc/tree-vect-patterns.cc
> @@ -2700,7 +2700,8 @@ vect_recog_bitfield_ref_pattern (vec_info *vinfo, stmt_vec_info stmt_info,
>    /* If the only use of the result of this BIT_FIELD_REF + CONVERT is a
>       PLUS_EXPR then do the shift last as some targets can combine the shift and
>       add into a single instruction.  */
> -  if (lhs && single_imm_use (lhs, &use_p, &use_stmt))
> +  if (lhs && !STMT_VINFO_RELATED_STMT (stmt_info)

!is_pattern_stmt_p (stmt_info)

should be clearer

OK with that change.

> +      && single_imm_use (lhs, &use_p, &use_stmt))
>      {
>        if (gimple_code (use_stmt) == GIMPLE_ASSIGN
>           && gimple_assign_rhs_code (use_stmt) == PLUS_EXPR)
> --
> 2.17.1
>
  

Patch

From 52e1725339fc7e4552eb7916570790c4ab7f133d Mon Sep 17 00:00:00 2001
From: Feng Xue <fxue@os.amperecomputing.com>
Date: Fri, 14 Jun 2024 15:49:23 +0800
Subject: [PATCH 1/5] vect: Fix single_imm_use in tree_vect_patterns

Since pattern statement coexists with normal statements in a way that it is
not linked into function body, we should not invoke utility procedures that
depends on def/use graph on pattern statement, such as counting uses of a
pseudo value defined by a pattern statement. This patch is to fix a bug of
this type in vect pattern formation.

2024-06-14 Feng Xue <fxue@os.amperecomputing.com>

gcc/
	* tree-vect-patterns.cc (vect_recog_bitfield_ref_pattern): Only call
	single_imm_use if statement is not generated by pattern recognition.
---
 gcc/tree-vect-patterns.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 4570c25b664..ca8809e7cfd 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -2700,7 +2700,8 @@  vect_recog_bitfield_ref_pattern (vec_info *vinfo, stmt_vec_info stmt_info,
   /* If the only use of the result of this BIT_FIELD_REF + CONVERT is a
      PLUS_EXPR then do the shift last as some targets can combine the shift and
      add into a single instruction.  */
-  if (lhs && single_imm_use (lhs, &use_p, &use_stmt))
+  if (lhs && !STMT_VINFO_RELATED_STMT (stmt_info)
+      && single_imm_use (lhs, &use_p, &use_stmt))
     {
       if (gimple_code (use_stmt) == GIMPLE_ASSIGN
 	  && gimple_assign_rhs_code (use_stmt) == PLUS_EXPR)
-- 
2.17.1