On Tue, Jun 30, 2026 at 11:57 AM Christopher Bazley
<[email protected]> wrote:
>
> Hi Richard B,
>
> I have incorporated Richard S's proposal into my patch. I think you were
> happy with this version. OK for trunk?

OK.

Note I got 4 mails from the forge, with different amount of details of the patch
which I find a bit confusing.  Can we improve this?

Thanks,
Richard.

>
> Thanks.
>
>
> On 30/06/2026 10:49, Christopher Bazley via Sourceware Forge wrote:
> > From: Christopher Bazley <[email protected]>
> >
> > 'nelts' is not the number of encoded elements in a VECTOR_CST; it
> > is the number of patterns. Sometimes those interpretations coincide,
> > as in the case of fixed length vector types (for which the number of
> > elements per pattern is one), but not always.
> >
> > 'step' is not the step between the second and third element of
> > a stepped pattern; it is the number of elements per pattern.
> > This has led to confusion on the mailing list.
> >
> > Both variables are hereby renamed and the code that assigns their
> > values refactored to be more palatable.
> >
> > gcc/ChangeLog:
> >
> >       * tree.cc (build_vector_from_ctor): Rename variables and
> >       refactor assignments.
> >
> > Co-authored-by: Richard Sandiford <[email protected]>
> > ---
> >   gcc/tree.cc | 17 +++++++----------
> >   1 file changed, 7 insertions(+), 10 deletions(-)
> >
> > diff --git a/gcc/tree.cc b/gcc/tree.cc
> > index ca713cec4d6a..e578001f103b 100644
> > --- a/gcc/tree.cc
> > +++ b/gcc/tree.cc
> > @@ -2201,23 +2201,20 @@ build_vector_from_ctor (tree type, const 
> > vec<constructor_elt, va_gc> *v)
> >     if (vec_safe_length (v) == 0)
> >       return build_zero_cst (type);
> >
> > -  unsigned HOST_WIDE_INT idx, nelts, step = 1;
> > +  unsigned HOST_WIDE_INT idx, npatterns, nelts_per_pattern;
> >     tree value;
> >
> >     /* If the vector is a VLA, build a VLA constant vector.  */
> > -  if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&nelts))
> > -    {
> > -      nelts = constant_lower_bound (TYPE_VECTOR_SUBPARTS (type));
> > -      gcc_assert (vec_safe_length (v) <= nelts);
> > -      step = 2;
> > -    }
> > +  npatterns = constant_lower_bound (TYPE_VECTOR_SUBPARTS (type));
> > +  nelts_per_pattern = TYPE_VECTOR_SUBPARTS (type).is_constant () ? 1 : 2;
> > +  gcc_assert (vec_safe_length (v) <= npatterns);
> >
> > -  tree_vector_builder vec (type, nelts, step);
> > +  tree_vector_builder vec (type, npatterns, nelts_per_pattern);
> >     FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value)
> >       {
> >         if (TREE_CODE (value) == VECTOR_CST)
> >       {
> > -       /* If NELTS is constant then this must be too.  */
> > +       /* If NPATTERNS is constant then this must be too.  */
> >         unsigned int sub_nelts = VECTOR_CST_NELTS (value).to_constant ();
> >         for (unsigned i = 0; i < sub_nelts; ++i)
> >           vec.quick_push (VECTOR_CST_ELT (value, i));
> > @@ -2225,7 +2222,7 @@ build_vector_from_ctor (tree type, const 
> > vec<constructor_elt, va_gc> *v)
> >         else
> >       vec.quick_push (value);
> >       }
> > -  while (vec.length () < nelts * step)
> > +  while (vec.length () < npatterns * nelts_per_pattern)
> >       vec.quick_push (build_zero_cst (TREE_TYPE (type)));
> >
> >     return vec.build ();
>
>
> --
> Christopher Bazley
> Staff Software Engineer, GNU Tools Team.
> Arm Ltd, 110 Fulbourn Road, Cambridge, CB1 9NJ, UK.
> http://www.arm.com/

Reply via email to