Hi gcc-patches mailing list,
Christopher Bazley via Sourceware Forge 
<[email protected]> has requested that the 
following forgejo pull request
be published on the mailing list.

Created on: 2026-06-23 10:46:06+00:00
Latest update: 2026-06-30 09:39:19+00:00
Changes: 1 changed files, 7 additions, 10 deletions
Head revision: chris.bazley/gcc ref horrible_confusion commit 
4266718b0e60599cff2a2b16f6dd92f372cb1e65
Base revision: gcc/gcc-TEST ref trunk commit 
6f7c038eee71e519571df5741413f0547fbe85a7 r16-7145-g6f7c038eee71e5
Merge base: 6f7c038eee71e519571df5741413f0547fbe85a7
Full diff url: https://forge.sourceware.org/gcc/gcc-TEST/pulls/182.diff
Discussion:  https://forge.sourceware.org/gcc/gcc-TEST/pulls/182
Requested Reviewers:

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

gcc/ChangeLog:

        * tree.cc (build_vector_from_ctor): Rename variables.


Changed files:
- M: gcc/tree.cc


Christopher Bazley (1):
  Fix confusing variable names in build_vector_from_ctor

 gcc/tree.cc | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Range-diff against v2:
1:  9bd127b31988 ! 1:  4266718b0e60 Fix confusing variable names in 
build_vector_from_ctor
    @@ Commit message
         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.
    +    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.
    +            * tree.cc (build_vector_from_ctor): Rename variables and
    +            refactor assignments.
     
      ## gcc/tree.cc ##
     @@ gcc/tree.cc: build_vector_from_ctor (tree type, const 
vec<constructor_elt, va_gc> *v)
    @@ gcc/tree.cc: build_vector_from_ctor (tree type, const 
vec<constructor_elt, va_gc
          return build_zero_cst (type);
      
     -  unsigned HOST_WIDE_INT idx, nelts, step = 1;
    -+  unsigned HOST_WIDE_INT idx, npatterns, nelts_per_pattern = 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))
    -+  if (!TYPE_VECTOR_SUBPARTS (type).is_constant (&npatterns))
    -     {
    +-    {
     -      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));
    -+      gcc_assert (vec_safe_length (v) <= npatterns);
    -+      nelts_per_pattern = 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);
-- 
2.54.0

Reply via email to