diff mbox series

[6/8] vect: Tighten an assertion for lane-reducing in transform

Message ID LV2PR01MB78396BF4C87EDBBE237345A3F7CC2@LV2PR01MB7839.prod.exchangelabs.com
State New
Headers show
Series [PATH,1/8] vect: Add a function to check lane-reducing stmt | expand

Commit Message

Feng Xue OS June 16, 2024, 7:28 a.m. UTC
According to logic of code nearby the assertion, all lane-reducing operations
should not appear, not just DOT_PROD_EXPR. Since "use_mask_by_cond_expr_p"
treats SAD_EXPR same as DOT_PROD_EXPR, and WIDEN_SUM_EXPR should not be allowed
by the following assertion "gcc_assert (commutative_binary_op_p (...))", so
tighten the assertion.

Thanks,
Feng

---
gcc/
	* tree-vect-loop.cc (vect_transform_reduction): Change assertion to
	cover all lane-reducing ops.
---
 gcc/tree-vect-loop.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Richard Biener June 19, 2024, 1:02 p.m. UTC | #1
On Sun, Jun 16, 2024 at 9:28 AM Feng Xue OS <fxue@os.amperecomputing.com> wrote:
>
> According to logic of code nearby the assertion, all lane-reducing operations
> should not appear, not just DOT_PROD_EXPR. Since "use_mask_by_cond_expr_p"
> treats SAD_EXPR same as DOT_PROD_EXPR, and WIDEN_SUM_EXPR should not be allowed
> by the following assertion "gcc_assert (commutative_binary_op_p (...))", so
> tighten the assertion.

OK.

Thanks,
Richard.

> Thanks,
> Feng
>
> ---
> gcc/
>         * tree-vect-loop.cc (vect_transform_reduction): Change assertion to
>         cover all lane-reducing ops.
> ---
>  gcc/tree-vect-loop.cc | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 7909d63d4df..e0561feddce 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -8643,7 +8643,8 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
>      }
>
>    bool single_defuse_cycle = STMT_VINFO_FORCE_SINGLE_CYCLE (reduc_info);
> -  gcc_assert (single_defuse_cycle || lane_reducing_op_p (code));
> +  bool lane_reducing = lane_reducing_op_p (code);
> +  gcc_assert (single_defuse_cycle || lane_reducing);
>
>    /* Create the destination vector  */
>    tree scalar_dest = gimple_get_lhs (stmt_info->stmt);
> @@ -8698,8 +8699,9 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
>        tree vop[3] = { vec_oprnds[0][i], vec_oprnds[1][i], NULL_TREE };
>        if (masked_loop_p && !mask_by_cond_expr)
>         {
> -         /* No conditional ifns have been defined for dot-product yet.  */
> -         gcc_assert (code != DOT_PROD_EXPR);
> +         /* No conditional ifns have been defined for lane-reducing op
> +            yet.  */
> +         gcc_assert (!lane_reducing);
>
>           /* Make sure that the reduction accumulator is vop[0].  */
>           if (reduc_index == 1)
> --
> 2.17.1
diff mbox series

Patch

From d348e63c001e65067876a80dfae75abefe10c240 Mon Sep 17 00:00:00 2001
From: Feng Xue <fxue@os.amperecomputing.com>
Date: Sun, 16 Jun 2024 13:33:52 +0800
Subject: [PATCH 6/8] vect: Tighten an assertion for lane-reducing in transform

According to logic of code nearby the assertion, all lane-reducing operations
should not appear, not just DOT_PROD_EXPR. Since "use_mask_by_cond_expr_p"
treats SAD_EXPR same as DOT_PROD_EXPR, and WIDEN_SUM_EXPR should not be allowed
by the following assertion "gcc_assert (commutative_binary_op_p (...))", so
tighten the assertion.

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

gcc/
	* tree-vect-loop.cc (vect_transform_reduction): Change assertion to
	cover all lane-reducing ops.
---
 gcc/tree-vect-loop.cc | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 7909d63d4df..e0561feddce 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8643,7 +8643,8 @@  vect_transform_reduction (loop_vec_info loop_vinfo,
     }
 
   bool single_defuse_cycle = STMT_VINFO_FORCE_SINGLE_CYCLE (reduc_info);
-  gcc_assert (single_defuse_cycle || lane_reducing_op_p (code));
+  bool lane_reducing = lane_reducing_op_p (code);
+  gcc_assert (single_defuse_cycle || lane_reducing);
 
   /* Create the destination vector  */
   tree scalar_dest = gimple_get_lhs (stmt_info->stmt);
@@ -8698,8 +8699,9 @@  vect_transform_reduction (loop_vec_info loop_vinfo,
       tree vop[3] = { vec_oprnds[0][i], vec_oprnds[1][i], NULL_TREE };
       if (masked_loop_p && !mask_by_cond_expr)
 	{
-	  /* No conditional ifns have been defined for dot-product yet.  */
-	  gcc_assert (code != DOT_PROD_EXPR);
+	  /* No conditional ifns have been defined for lane-reducing op
+	     yet.  */
+	  gcc_assert (!lane_reducing);
 
 	  /* Make sure that the reduction accumulator is vop[0].  */
 	  if (reduc_index == 1)
-- 
2.17.1