> >> So I think we can simply set const_n_elts to CONSTRUCTOR_NELTS
> >> for vector_typed_elts_p?
> >>
> >

Done,

gcc/ChangeLog:

        PR target/96342
        * expr.cc (store_constructor): add support for variable-length
        vectors.

Co-authored-by: Tamar Christina <tamar.christ...@arm.com>

Bootstrapped Regtested on aarch64-none-linux-gnu,
arm-none-linux-gnueabihf, x86_64-pc-linux-gnu
-m32, -m64 and no issues.

Ok for master?

Thanks,
Tamar

-- inline copy of patch --

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 
4c6039c6608c0d9db3d1796eeab2129cb844433f..babf00f34dcf1ac81a9d2d9947350fb1c0455811
 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -7965,12 +7965,9 @@ store_constructor (tree exp, rtx target, int cleared, 
poly_int64 size,
 
        n_elts = TYPE_VECTOR_SUBPARTS (type);
        if (REG_P (target)
-           && VECTOR_MODE_P (mode)
-           && n_elts.is_constant (&const_n_elts))
+           && VECTOR_MODE_P (mode))
          {
-           machine_mode emode = eltmode;
-           bool vector_typed_elts_p = false;
-
+           const_n_elts = 0;
            if (CONSTRUCTOR_NELTS (exp)
                && (TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (exp, 0)->value))
                    == VECTOR_TYPE))
@@ -7979,23 +7976,26 @@ store_constructor (tree exp, rtx target, int cleared, 
poly_int64 size,
                gcc_assert (known_eq (CONSTRUCTOR_NELTS (exp)
                                      * TYPE_VECTOR_SUBPARTS (etype),
                                      n_elts));
-               emode = TYPE_MODE (etype);
-               vector_typed_elts_p = true;
+
+               icode = convert_optab_handler (vec_init_optab, mode,
+                                              TYPE_MODE (etype));
+               const_n_elts = CONSTRUCTOR_NELTS (exp);
+               vec_vec_init_p = icode != CODE_FOR_nothing;
              }
-           icode = convert_optab_handler (vec_init_optab, mode, emode);
-           if (icode != CODE_FOR_nothing)
+           else if (exact_div (n_elts, GET_MODE_NUNITS (eltmode))
+                       .is_constant (&const_n_elts))
              {
-               unsigned int n = const_n_elts;
-
-               if (vector_typed_elts_p)
-                 {
-                   n = CONSTRUCTOR_NELTS (exp);
-                   vec_vec_init_p = true;
-                 }
-               vector = rtvec_alloc (n);
-               for (unsigned int k = 0; k < n; k++)
-                 RTVEC_ELT (vector, k) = CONST0_RTX (emode);
+               /* For a non-const type vector, we check it is made up of
+                  similarly non-const type vectors. */
+               icode = convert_optab_handler (vec_init_optab, mode, eltmode);
              }
+
+         if (const_n_elts && icode != CODE_FOR_nothing)
+           {
+             vector = rtvec_alloc (const_n_elts);
+             for (unsigned int k = 0; k < const_n_elts; k++)
+               RTVEC_ELT (vector, k) = CONST0_RTX (eltmode);
+           }
          }
 
        /* Compute the size of the elements in the CTOR.  It differs

Attachment: rb19030.patch
Description: rb19030.patch

Reply via email to