[v3] vect: Verify that GET_MODE_UNITS is greater than one for vect_grouped_store_supported

Message ID 20230417163856.2253309-1-kevinl@rivosinc.com
State Accepted
Headers
Series [v3] vect: Verify that GET_MODE_UNITS is greater than one for vect_grouped_store_supported |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Kevin Lee April 17, 2023, 4:38 p.m. UTC
  This patch properly guards gcc_assert (multiple_p (m_full_nelts, 
m_npatterns)) in vec_perm_indices indices (sel, 2, nelt) for VNx1 vectors.

Based on the feedback from Richard Biener and Richard Sandiford,
multiple_p has been used instead of maybe_lt to compare nelt with the
minimum size 2.

Bootstrap and testing done on x86_64-pc-linux-gnu. Would this be ok for trunk?

Patch V1: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html
Patch V2: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614700.html
 
Kevin Lee <kevinl@rivosinc.com>
gcc/ChangeLog:

	* tree-vect-data-refs.cc (vect_grouped_store_supported): Add new
condition
---
 gcc/tree-vect-data-refs.cc | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Richard Biener April 18, 2023, 6:08 a.m. UTC | #1
On Mon, Apr 17, 2023 at 6:40 PM Kevin Lee <kevinl@rivosinc.com> wrote:
>
> This patch properly guards gcc_assert (multiple_p (m_full_nelts,
> m_npatterns)) in vec_perm_indices indices (sel, 2, nelt) for VNx1 vectors.
>
> Based on the feedback from Richard Biener and Richard Sandiford,
> multiple_p has been used instead of maybe_lt to compare nelt with the
> minimum size 2.
>
> Bootstrap and testing done on x86_64-pc-linux-gnu. Would this be ok for trunk?

Yes, this is OK.

Thanks,
Richard.

> Patch V1: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html
> Patch V2: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614700.html
>
> Kevin Lee <kevinl@rivosinc.com>
> gcc/ChangeLog:
>
>         * tree-vect-data-refs.cc (vect_grouped_store_supported): Add new
> condition
> ---
>  gcc/tree-vect-data-refs.cc | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
> index 8daf7bd7dd3..df393ba723d 100644
> --- a/gcc/tree-vect-data-refs.cc
> +++ b/gcc/tree-vect-data-refs.cc
> @@ -5399,6 +5399,8 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
>           poly_uint64 nelt = GET_MODE_NUNITS (mode);
>
>           /* The encoding has 2 interleaved stepped patterns.  */
> +    if(!multiple_p (nelt, 2))
> +      return false;
>           vec_perm_builder sel (nelt, 2, 3);
>           sel.quick_grow (6);
>           for (i = 0; i < 3; i++)
> --
> 2.25.1
>
  
Jeff Law April 18, 2023, 6:43 p.m. UTC | #2
On 4/17/23 10:38, Kevin Lee wrote:
> This patch properly guards gcc_assert (multiple_p (m_full_nelts,
> m_npatterns)) in vec_perm_indices indices (sel, 2, nelt) for VNx1 vectors.
> 
> Based on the feedback from Richard Biener and Richard Sandiford,
> multiple_p has been used instead of maybe_lt to compare nelt with the
> minimum size 2.
> 
> Bootstrap and testing done on x86_64-pc-linux-gnu. Would this be ok for trunk?
> 
> Patch V1: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html
> Patch V2: https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614700.html
>   
> Kevin Lee <kevinl@rivosinc.com>
> gcc/ChangeLog:
> 
> 	* tree-vect-data-refs.cc (vect_grouped_store_supported): Add new
> condition.
I fixed up the indentation and pushed this to the trunk.

jeff
  

Patch

diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 8daf7bd7dd3..df393ba723d 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -5399,6 +5399,8 @@  vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
 	  poly_uint64 nelt = GET_MODE_NUNITS (mode);
 
 	  /* The encoding has 2 interleaved stepped patterns.  */
+    if(!multiple_p (nelt, 2))
+      return false;
 	  vec_perm_builder sel (nelt, 2, 3);
 	  sel.quick_grow (6);
 	  for (i = 0; i < 3; i++)