* [PATCH] middle-end/110541 - VEC_PERM_EXPR documentation is off
@ 2023-07-05 6:57 Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-07-05 6:57 UTC (permalink / raw)
To: gcc-patches; +Cc: richard.sandiford
The following adjusts the tree.def documentation about VEC_PERM_EXPR
which wasn't adjusted when the restrictions of permutes with constant
mask were relaxed.
OK?
Thanks,
Richard.
PR middle-end/110541
* tree.def (VEC_PERM_EXPR): Adjust documentation to reflect
reality.
---
gcc/tree.def | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/gcc/tree.def b/gcc/tree.def
index 1fc2ca7a724..9e1a54ac2f9 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -565,13 +565,20 @@ DEFTREECODE (VEC_COND_EXPR, "vec_cond_expr", tcc_expression, 3)
N = length(mask)
foreach i in N:
- M = mask[i] % (2*N)
- A = M < N ? v0[M] : v1[M-N]
+ M = mask[i] % (length(v0) + length(v1))
+ A[i] = M < length(v0) ? v0[M] : v1[M - length(v0)]
- V0 and V1 are vectors of the same type. MASK is an integer-typed
- vector. The number of MASK elements must be the same with the
- number of elements in V0 and V1. The size of the inner type
- of the MASK and of the V0 and V1 must be the same.
+ V0 and V1 are vectors of the same type.
+
+ When MASK is not constant:
+ MASK is an integer-typed vector. The number of MASK elements must
+ be the same with the number of elements in V0 and V1. The size of
+ the inner type of the MASK and of the V0 and V1 must be the same.
+
+ When MASK is constant:
+ MASK is an integer-typed vector. MASK elements outside of
+ [0, length(V0) + length(V1) - 1] invoke undefined behavior (the
+ modulo operation above doesn't apply).
*/
DEFTREECODE (VEC_PERM_EXPR, "vec_perm_expr", tcc_expression, 3)
--
2.35.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] middle-end/110541 - VEC_PERM_EXPR documentation is off
2023-07-05 7:39 ` Richard Sandiford
@ 2023-07-05 7:47 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2023-07-05 7:47 UTC (permalink / raw)
To: Richard Sandiford; +Cc: Richard Biener via Gcc-patches
On Wed, 5 Jul 2023, Richard Sandiford wrote:
> Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> > The following adjusts the tree.def documentation about VEC_PERM_EXPR
> > which wasn't adjusted when the restrictions of permutes with constant
> > mask were relaxed.
>
> I was going to complain about having two copies of the documentation,
> but then I realised that generic.texi doesn't document VEC_PERM_EXPR.
> So... oops.
Yeah, also noticed that ...
> >
> > OK?
> >
> > Thanks,
> > Richard.
> >
> > PR middle-end/110541
> > * tree.def (VEC_PERM_EXPR): Adjust documentation to reflect
> > reality.
> > ---
> > gcc/tree.def | 19 +++++++++++++------
> > 1 file changed, 13 insertions(+), 6 deletions(-)
> >
> > diff --git a/gcc/tree.def b/gcc/tree.def
> > index 1fc2ca7a724..9e1a54ac2f9 100644
> > --- a/gcc/tree.def
> > +++ b/gcc/tree.def
> > @@ -565,13 +565,20 @@ DEFTREECODE (VEC_COND_EXPR, "vec_cond_expr", tcc_expression, 3)
> >
> > N = length(mask)
> > foreach i in N:
> > - M = mask[i] % (2*N)
> > - A = M < N ? v0[M] : v1[M-N]
> > + M = mask[i] % (length(v0) + length(v1))
> > + A[i] = M < length(v0) ? v0[M] : v1[M - length(v0)]
> >
> > - V0 and V1 are vectors of the same type. MASK is an integer-typed
> > - vector. The number of MASK elements must be the same with the
> > - number of elements in V0 and V1. The size of the inner type
> > - of the MASK and of the V0 and V1 must be the same.
> > + V0 and V1 are vectors of the same type.
> > +
> > + When MASK is not constant:
> > + MASK is an integer-typed vector. The number of MASK elements must
> > + be the same with the number of elements in V0 and V1. The size of
>
> Preexisting, but s/same with/same as/
Fixed.
> > + the inner type of the MASK and of the V0 and V1 must be the same.
> > +
> > + When MASK is constant:
> > + MASK is an integer-typed vector. MASK elements outside of
> > + [0, length(V0) + length(V1) - 1] invoke undefined behavior (the
> > + modulo operation above doesn't apply).
>
> I don't remember the last rule. I thought the modulo did still apply.
> (But the canonical form is to remove obvious modulo opportunities.)
>
> E.g. a VLA reverse-and-rotate pattern might have { N-2, N-3, N-4, ... }.
> That will wrap at the final position to 2N-1, but that seems OK.
OK, I'll remove that sentence.
Pushed as follows.
Richard.
From 38f2d33e5119e6ae39f2702caced7e9b224cbc4f Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
Date: Wed, 5 Jul 2023 08:53:01 +0200
Subject: [PATCH] middle-end/110541 - VEC_PERM_EXPR documentation is off
To: gcc-patches@gcc.gnu.org
The following adjusts the tree.def documentation about VEC_PERM_EXPR
which wasn't adjusted when the restrictions of permutes with constant
mask were relaxed.
PR middle-end/110541
* tree.def (VEC_PERM_EXPR): Adjust documentation to reflect
reality.
---
gcc/tree.def | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/gcc/tree.def b/gcc/tree.def
index 1fc2ca7a724..be94b7ece0a 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -565,13 +565,18 @@ DEFTREECODE (VEC_COND_EXPR, "vec_cond_expr", tcc_expression, 3)
N = length(mask)
foreach i in N:
- M = mask[i] % (2*N)
- A = M < N ? v0[M] : v1[M-N]
+ M = mask[i] % (length(v0) + length(v1))
+ A[i] = M < length(v0) ? v0[M] : v1[M - length(v0)]
- V0 and V1 are vectors of the same type. MASK is an integer-typed
- vector. The number of MASK elements must be the same with the
- number of elements in V0 and V1. The size of the inner type
- of the MASK and of the V0 and V1 must be the same.
+ V0 and V1 are vectors of the same type.
+
+ When MASK is not constant:
+ MASK is an integer-typed vector. The number of MASK elements must
+ be the same as the number of elements in V0 and V1. The size of
+ the inner type of the MASK and of the V0 and V1 must be the same.
+
+ When MASK is constant:
+ MASK is an integer-typed vector.
*/
DEFTREECODE (VEC_PERM_EXPR, "vec_perm_expr", tcc_expression, 3)
--
2.35.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] middle-end/110541 - VEC_PERM_EXPR documentation is off
[not found] <20230705065744.2EA503857C48@sourceware.org>
@ 2023-07-05 7:39 ` Richard Sandiford
2023-07-05 7:47 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Richard Sandiford @ 2023-07-05 7:39 UTC (permalink / raw)
To: Richard Biener via Gcc-patches; +Cc: Richard Biener
Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> The following adjusts the tree.def documentation about VEC_PERM_EXPR
> which wasn't adjusted when the restrictions of permutes with constant
> mask were relaxed.
I was going to complain about having two copies of the documentation,
but then I realised that generic.texi doesn't document VEC_PERM_EXPR.
So... oops.
>
> OK?
>
> Thanks,
> Richard.
>
> PR middle-end/110541
> * tree.def (VEC_PERM_EXPR): Adjust documentation to reflect
> reality.
> ---
> gcc/tree.def | 19 +++++++++++++------
> 1 file changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/tree.def b/gcc/tree.def
> index 1fc2ca7a724..9e1a54ac2f9 100644
> --- a/gcc/tree.def
> +++ b/gcc/tree.def
> @@ -565,13 +565,20 @@ DEFTREECODE (VEC_COND_EXPR, "vec_cond_expr", tcc_expression, 3)
>
> N = length(mask)
> foreach i in N:
> - M = mask[i] % (2*N)
> - A = M < N ? v0[M] : v1[M-N]
> + M = mask[i] % (length(v0) + length(v1))
> + A[i] = M < length(v0) ? v0[M] : v1[M - length(v0)]
>
> - V0 and V1 are vectors of the same type. MASK is an integer-typed
> - vector. The number of MASK elements must be the same with the
> - number of elements in V0 and V1. The size of the inner type
> - of the MASK and of the V0 and V1 must be the same.
> + V0 and V1 are vectors of the same type.
> +
> + When MASK is not constant:
> + MASK is an integer-typed vector. The number of MASK elements must
> + be the same with the number of elements in V0 and V1. The size of
Preexisting, but s/same with/same as/
> + the inner type of the MASK and of the V0 and V1 must be the same.
> +
> + When MASK is constant:
> + MASK is an integer-typed vector. MASK elements outside of
> + [0, length(V0) + length(V1) - 1] invoke undefined behavior (the
> + modulo operation above doesn't apply).
I don't remember the last rule. I thought the modulo did still apply.
(But the canonical form is to remove obvious modulo opportunities.)
E.g. a VLA reverse-and-rotate pattern might have { N-2, N-3, N-4, ... }.
That will wrap at the final position to 2N-1, but that seems OK.
LGTM otherwise FWIW.
Thanks,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-05 7:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 6:57 [PATCH] middle-end/110541 - VEC_PERM_EXPR documentation is off Richard Biener
[not found] <20230705065744.2EA503857C48@sourceware.org>
2023-07-05 7:39 ` Richard Sandiford
2023-07-05 7:47 ` Richard Biener
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).