public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one.
@ 2023-03-14 21:52 Michael Collison
  2023-03-19 16:58 ` Jeff Law
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Collison @ 2023-03-14 21:52 UTC (permalink / raw)
  To: gcc-patches

While working on autovectorizing for the RISCV port I encountered an issue
where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a
evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode),
where GET_MODE_NUNITS is equal to one.

Tested on RISCV and x86_64-linux-gnu. Okay?

2023-03-09  Michael Collison  <collison@rivosinc.com>

	* tree-vect-slp.cc (can_duplicate_and_interleave_p):
	Check that GET_MODE_NUNITS is greater than one.
---
 gcc/tree-vect-slp.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 9a4e000925e..add58113fa8 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -426,7 +426,8 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count,
 	  if (vector_type
 	      && VECTOR_MODE_P (TYPE_MODE (vector_type))
 	      && known_eq (GET_MODE_SIZE (TYPE_MODE (vector_type)),
-			   GET_MODE_SIZE (base_vector_mode)))
+			   GET_MODE_SIZE (base_vector_mode))
+	      && known_gt (GET_MODE_NUNITS (TYPE_MODE (vector_type)), 1))
 	    {
 	      /* Try fusing consecutive sequences of COUNT / NVECTORS elements
 		 together into elements of type INT_TYPE and using the result
-- 
2.34.1


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

* Re: [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one.
  2023-03-14 21:52 [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one Michael Collison
@ 2023-03-19 16:58 ` Jeff Law
  2023-03-31  9:58 ` Richard Sandiford
  2023-04-22  0:23 ` Jeff Law
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2023-03-19 16:58 UTC (permalink / raw)
  To: Michael Collison, gcc-patches



On 3/14/23 15:52, Michael Collison wrote:
> While working on autovectorizing for the RISCV port I encountered an issue
> where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a
> evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode),
> where GET_MODE_NUNITS is equal to one.
> 
> Tested on RISCV and x86_64-linux-gnu. Okay?
> 
> 2023-03-09  Michael Collison  <collison@rivosinc.com>
> 
> 	* tree-vect-slp.cc (can_duplicate_and_interleave_p):
> 	Check that GET_MODE_NUNITS is greater than one.
As far as I know this doesn't fix a regression so I would defer to 
gc-14.  As release managers, Richi, Jakub or Joseph can gate it in as an 
exception.

jeff

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

* Re: [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one.
  2023-03-14 21:52 [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one Michael Collison
  2023-03-19 16:58 ` Jeff Law
@ 2023-03-31  9:58 ` Richard Sandiford
  2023-04-22  0:23 ` Jeff Law
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Sandiford @ 2023-03-31  9:58 UTC (permalink / raw)
  To: Michael Collison; +Cc: gcc-patches

Michael Collison <collison@rivosinc.com> writes:
> While working on autovectorizing for the RISCV port I encountered an issue
> where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a
> evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode),
> where GET_MODE_NUNITS is equal to one.
>
> Tested on RISCV and x86_64-linux-gnu. Okay?
>
> 2023-03-09  Michael Collison  <collison@rivosinc.com>
>
> 	* tree-vect-slp.cc (can_duplicate_and_interleave_p):
> 	Check that GET_MODE_NUNITS is greater than one.
> ---
>  gcc/tree-vect-slp.cc | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
> index 9a4e000925e..add58113fa8 100644
> --- a/gcc/tree-vect-slp.cc
> +++ b/gcc/tree-vect-slp.cc
> @@ -426,7 +426,8 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count,
>  	  if (vector_type
>  	      && VECTOR_MODE_P (TYPE_MODE (vector_type))
>  	      && known_eq (GET_MODE_SIZE (TYPE_MODE (vector_type)),
> -			   GET_MODE_SIZE (base_vector_mode)))
> +			   GET_MODE_SIZE (base_vector_mode))
> +	      && known_gt (GET_MODE_NUNITS (TYPE_MODE (vector_type)), 1))
>  	    {
>  	      /* Try fusing consecutive sequences of COUNT / NVECTORS elements
>  		 together into elements of type INT_TYPE and using the result

FWIW, I think it'd better to remove:

	      poly_int64 half_nelts = exact_div (nelts, 2);

declare:

	  poly_uint64 half_nelts;

before the if condition, and use:

	    && multiple_p (GET_MODE_NUNITS (TYPE_MODE (vector_type)),
			   2, &half_nelts)

instead of the known_gt.  In other words, now that we can't assert
the exact_div, we should check it (using multiple_p) instead.

Thanks,
Richard

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

* Re: [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one.
  2023-03-14 21:52 [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one Michael Collison
  2023-03-19 16:58 ` Jeff Law
  2023-03-31  9:58 ` Richard Sandiford
@ 2023-04-22  0:23 ` Jeff Law
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2023-04-22  0:23 UTC (permalink / raw)
  To: Michael Collison, gcc-patches



On 3/14/23 15:52, Michael Collison wrote:
> While working on autovectorizing for the RISCV port I encountered an issue
> where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a
> evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode),
> where GET_MODE_NUNITS is equal to one.
> 
> Tested on RISCV and x86_64-linux-gnu. Okay?
> 
> 2023-03-09  Michael Collison  <collison@rivosinc.com>
> 
> 	* tree-vect-slp.cc (can_duplicate_and_interleave_p):
> 	Check that GET_MODE_NUNITS is greater than one.
Is this still relevant?   I know other changes were made to deal with 
the case where GET_MODE_NUNITS returns 1, but I don't know if they made 
this obsolete.

Any chance we could get a testcase for this?  I realize it might depend 
on unmerged RVV bits.


jeff

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

end of thread, other threads:[~2023-04-22  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 21:52 [PATCH] vect: Verify that GET_MODE_NUNITS is greater than one Michael Collison
2023-03-19 16:58 ` Jeff Law
2023-03-31  9:58 ` Richard Sandiford
2023-04-22  0:23 ` Jeff Law

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