public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989]
@ 2023-08-11 13:55 Juzhe-Zhong
  2023-08-11 13:56 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Juzhe-Zhong @ 2023-08-11 13:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.sandiford, rguenther, Juzhe-Zhong

This ICE is caused because of this situation:

mask__49.21_99 = vect__17.19_96 == { 0.0, ... };
...
vect__6.24_107 = .MASK_LEN_LOAD (vectp.22_105, 32B, mask__49.21_99, POLY_INT_CST [2, 2], 0);

The MASK_LEN_LOAD is using real MASK which is produced by the EQ comparison wheras the LEN
is the dummy LEN which is the vectorization factor.

In this situation, we didn't enter 'vect_record_loop_len' since there is no LEN loop control.
Then 'LOOP_VINFO_RGROUP_IV_TYPE' is not suitable type for 'build_int_cst' used for producing
LEN argument for 'MASK_LEN_LOAD', so use sizetype instead which is perfectly matching
RVV length requirement.

        PR middle-end/110989

gcc/ChangeLog:

        * tree-vect-stmts.cc (vectorizable_store): Replace iv_type with sizetype.
        (vectorizable_load): Ditto.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/rvv/autovec/pr110989.c: New test.

---
 .../gcc.target/riscv/rvv/autovec/pr110989.c          | 11 +++++++++++
 gcc/tree-vect-stmts.cc                               | 12 +++---------
 2 files changed, 14 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
new file mode 100644
index 00000000000..cf3b247e604
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d --param=riscv-autovec-preference=scalable -Ofast" } */
+
+int a, b, c;
+double *d;
+void e() {
+  double f;
+  for (; c; c++, d--)
+    f = *d ?: *(&a + c);
+  b = f;
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 398fbe945e5..89607a98f99 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -9125,11 +9125,8 @@ vectorizable_store (vec_info *vinfo,
 		  if (!final_len)
 		    {
 		      /* Pass VF value to 'len' argument of
-		         MASK_LEN_STORE if LOOP_LENS is invalid.  */
-		      tree iv_type = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo);
-		      final_len
-			= build_int_cst (iv_type,
-					 TYPE_VECTOR_SUBPARTS (vectype));
+			 MASK_LEN_STORE if LOOP_LENS is invalid.  */
+		      final_len = size_int (TYPE_VECTOR_SUBPARTS (vectype));
 		    }
 		  if (!final_mask)
 		    {
@@ -10713,11 +10710,8 @@ vectorizable_load (vec_info *vinfo,
 			  {
 			    /* Pass VF value to 'len' argument of
 			       MASK_LEN_LOAD if LOOP_LENS is invalid.  */
-			    tree iv_type
-			      = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo);
 			    final_len
-			      = build_int_cst (iv_type,
-					       TYPE_VECTOR_SUBPARTS (vectype));
+			      = size_int (TYPE_VECTOR_SUBPARTS (vectype));
 			  }
 			if (!final_mask)
 			  {
-- 
2.36.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989]
  2023-08-11 13:55 [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989] Juzhe-Zhong
@ 2023-08-11 13:56 ` Richard Biener
  2023-08-11 21:51   ` Li, Pan2
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2023-08-11 13:56 UTC (permalink / raw)
  To: Juzhe-Zhong; +Cc: gcc-patches, richard.sandiford

On Fri, 11 Aug 2023, Juzhe-Zhong wrote:

> This ICE is caused because of this situation:
> 
> mask__49.21_99 = vect__17.19_96 == { 0.0, ... };
> ...
> vect__6.24_107 = .MASK_LEN_LOAD (vectp.22_105, 32B, mask__49.21_99, POLY_INT_CST [2, 2], 0);
> 
> The MASK_LEN_LOAD is using real MASK which is produced by the EQ comparison wheras the LEN
> is the dummy LEN which is the vectorization factor.
> 
> In this situation, we didn't enter 'vect_record_loop_len' since there is no LEN loop control.
> Then 'LOOP_VINFO_RGROUP_IV_TYPE' is not suitable type for 'build_int_cst' used for producing
> LEN argument for 'MASK_LEN_LOAD', so use sizetype instead which is perfectly matching
> RVV length requirement.

OK.

>         PR middle-end/110989
> 
> gcc/ChangeLog:
> 
>         * tree-vect-stmts.cc (vectorizable_store): Replace iv_type with sizetype.
>         (vectorizable_load): Ditto.
> 
> gcc/testsuite/ChangeLog:
> 
>         * gcc.target/riscv/rvv/autovec/pr110989.c: New test.
> 
> ---
>  .../gcc.target/riscv/rvv/autovec/pr110989.c          | 11 +++++++++++
>  gcc/tree-vect-stmts.cc                               | 12 +++---------
>  2 files changed, 14 insertions(+), 9 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
> 
> diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
> new file mode 100644
> index 00000000000..cf3b247e604
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=riscv-autovec-preference=scalable -Ofast" } */
> +
> +int a, b, c;
> +double *d;
> +void e() {
> +  double f;
> +  for (; c; c++, d--)
> +    f = *d ?: *(&a + c);
> +  b = f;
> +}
> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
> index 398fbe945e5..89607a98f99 100644
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -9125,11 +9125,8 @@ vectorizable_store (vec_info *vinfo,
>  		  if (!final_len)
>  		    {
>  		      /* Pass VF value to 'len' argument of
> -		         MASK_LEN_STORE if LOOP_LENS is invalid.  */
> -		      tree iv_type = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo);
> -		      final_len
> -			= build_int_cst (iv_type,
> -					 TYPE_VECTOR_SUBPARTS (vectype));
> +			 MASK_LEN_STORE if LOOP_LENS is invalid.  */
> +		      final_len = size_int (TYPE_VECTOR_SUBPARTS (vectype));
>  		    }
>  		  if (!final_mask)
>  		    {
> @@ -10713,11 +10710,8 @@ vectorizable_load (vec_info *vinfo,
>  			  {
>  			    /* Pass VF value to 'len' argument of
>  			       MASK_LEN_LOAD if LOOP_LENS is invalid.  */
> -			    tree iv_type
> -			      = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo);
>  			    final_len
> -			      = build_int_cst (iv_type,
> -					       TYPE_VECTOR_SUBPARTS (vectype));
> +			      = size_int (TYPE_VECTOR_SUBPARTS (vectype));
>  			  }
>  			if (!final_mask)
>  			  {
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989]
  2023-08-11 13:56 ` Richard Biener
@ 2023-08-11 21:51   ` Li, Pan2
  0 siblings, 0 replies; 3+ messages in thread
From: Li, Pan2 @ 2023-08-11 21:51 UTC (permalink / raw)
  To: Richard Biener, Juzhe-Zhong; +Cc: gcc-patches, richard.sandiford

Committed, thanks Richard.

Pan

-----Original Message-----
From: Gcc-patches <gcc-patches-bounces+pan2.li=intel.com@gcc.gnu.org> On Behalf Of Richard Biener via Gcc-patches
Sent: Friday, August 11, 2023 9:57 PM
To: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Cc: gcc-patches@gcc.gnu.org; richard.sandiford@arm.com
Subject: Re: [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989]

On Fri, 11 Aug 2023, Juzhe-Zhong wrote:

> This ICE is caused because of this situation:
> 
> mask__49.21_99 = vect__17.19_96 == { 0.0, ... };
> ...
> vect__6.24_107 = .MASK_LEN_LOAD (vectp.22_105, 32B, mask__49.21_99, POLY_INT_CST [2, 2], 0);
> 
> The MASK_LEN_LOAD is using real MASK which is produced by the EQ comparison wheras the LEN
> is the dummy LEN which is the vectorization factor.
> 
> In this situation, we didn't enter 'vect_record_loop_len' since there is no LEN loop control.
> Then 'LOOP_VINFO_RGROUP_IV_TYPE' is not suitable type for 'build_int_cst' used for producing
> LEN argument for 'MASK_LEN_LOAD', so use sizetype instead which is perfectly matching
> RVV length requirement.

OK.

>         PR middle-end/110989
> 
> gcc/ChangeLog:
> 
>         * tree-vect-stmts.cc (vectorizable_store): Replace iv_type with sizetype.
>         (vectorizable_load): Ditto.
> 
> gcc/testsuite/ChangeLog:
> 
>         * gcc.target/riscv/rvv/autovec/pr110989.c: New test.
> 
> ---
>  .../gcc.target/riscv/rvv/autovec/pr110989.c          | 11 +++++++++++
>  gcc/tree-vect-stmts.cc                               | 12 +++---------
>  2 files changed, 14 insertions(+), 9 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
> 
> diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
> new file mode 100644
> index 00000000000..cf3b247e604
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr110989.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64gcv -mabi=lp64d --param=riscv-autovec-preference=scalable -Ofast" } */
> +
> +int a, b, c;
> +double *d;
> +void e() {
> +  double f;
> +  for (; c; c++, d--)
> +    f = *d ?: *(&a + c);
> +  b = f;
> +}
> diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
> index 398fbe945e5..89607a98f99 100644
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -9125,11 +9125,8 @@ vectorizable_store (vec_info *vinfo,
>  		  if (!final_len)
>  		    {
>  		      /* Pass VF value to 'len' argument of
> -		         MASK_LEN_STORE if LOOP_LENS is invalid.  */
> -		      tree iv_type = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo);
> -		      final_len
> -			= build_int_cst (iv_type,
> -					 TYPE_VECTOR_SUBPARTS (vectype));
> +			 MASK_LEN_STORE if LOOP_LENS is invalid.  */
> +		      final_len = size_int (TYPE_VECTOR_SUBPARTS (vectype));
>  		    }
>  		  if (!final_mask)
>  		    {
> @@ -10713,11 +10710,8 @@ vectorizable_load (vec_info *vinfo,
>  			  {
>  			    /* Pass VF value to 'len' argument of
>  			       MASK_LEN_LOAD if LOOP_LENS is invalid.  */
> -			    tree iv_type
> -			      = LOOP_VINFO_RGROUP_IV_TYPE (loop_vinfo);
>  			    final_len
> -			      = build_int_cst (iv_type,
> -					       TYPE_VECTOR_SUBPARTS (vectype));
> +			      = size_int (TYPE_VECTOR_SUBPARTS (vectype));
>  			  }
>  			if (!final_mask)
>  			  {
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-11 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11 13:55 [PATCH V2] VECT: Fix ICE on MASK_LEN_{LOAD,STORE} when no LEN recorded[PR110989] Juzhe-Zhong
2023-08-11 13:56 ` Richard Biener
2023-08-11 21:51   ` Li, Pan2

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