On Tue, Jun 16, 2026 at 5:52 PM Christopher Bazley <[email protected]> wrote:
>
> Hi Richard,
>
> On 09/06/2026 10:40, Richard Biener wrote:
> > On Wed, Jun 3, 2026 at 5:21 PM Christopher Bazley <[email protected]> 
> > wrote:
> >> @@ -8075,7 +8078,12 @@ store_constructor (tree exp, rtx target, int 
> >> cleared, poly_int64 size,
> >>                     similarly non-const type vectors. */
> >>                  icode = convert_optab_handler (vec_init_optab, mode, 
> >> eltmode);
> >>                }
> >> -
> >> +           else
> >> +             {
> >> +               /* Handle variable-length vector types.  */
> >> +               icode = convert_optab_handler (vec_init_optab, mode, 
> >> eltmode);
> >> +               const_n_elts = constant_lower_bound (n_elts);
> >> +             }
> >
> > And here I'd like to see
> >
> >              gcc_assert (icode != CODE_FOR_nothing);
>
>
> Unfortunately, I cannot make this requested change because it causes the
> compiler to crash in an existing test case, even if I restrict the scope
> of the assertion to the new 'else' block.

The 'else' block was where I wanted the assert to be, of course.

>
> Reproducer:
>
> make check-gcc RUNTESTFLAGS="aarch64-sve-acle.exp=cops_bool.c"
>
> Variable values:
>
> mode = E_VNx16BImode
> eltmode = E_QImode
> icode = CODE_FOR_nothing
>
> Backtrace:
>
> #0  fancy_abort (file=file@entry=0x255f858
> "/work/results_sc/src-patched/gcc/expr.cc", line=line@entry=8085,
> function=function@entry=0x25602a0 "store_constructor")
>      at /work/results_sc/src-patched/gcc/diagnostics/context.h:558
> #1  0x0000000000be9c98 in store_constructor
> (exp=exp@entry=0xfffff6577e58, target=target@entry=0xfffff605d408,
> cleared=cleared@entry=0, size=..., reverse=reverse@entry=false)
>      at /work/results_sc/src-patched/gcc/expr.cc:8085
> #2  0x0000000000bec00c in expand_constructor
> (exp=exp@entry=0xfffff6577e58, target=0xfffff605d408,
> target@entry=0xfffff605d3f0, modifier=modifier@entry=EXPAND_NORMAL,
> avoid_temp_mem=avoid_temp_mem@entry=false)
>      at /work/results_sc/src-patched/gcc/poly-int.h:470
> #3  0x0000000000bd21b8 in expand_expr_real_1 (exp=0xfffff6577e58,
> target=<optimized out>, tmode=E_VNx16BImode, modifier=EXPAND_NORMAL,
> alt_rtl=0x0, inner_reference_p=<optimized out>)
>      at /work/results_sc/src-patched/gcc/expr.cc:11943
> #4  0x0000000000bd845c in expand_expr_real_gassign
> (g=g@entry=0xfffff65a88f0, target=target@entry=0xfffff605d3f0,
> tmode=tmode@entry=E_VNx16BImode, modifier=modifier@entry=EXPAND_NORMAL,
>      alt_rtl=alt_rtl@entry=0x0,
> inner_reference_p=inner_reference_p@entry=false) at
> /work/results_sc/src-patched/gcc/gimple.h:2728
> #5  0x0000000000bd5604 in expand_expr_real_1
> (exp=exp@entry=0xfffff65bf318, target=<optimized out>,
> tmode=E_VNx16BImode, modifier=EXPAND_NORMAL, alt_rtl=0x0,
> inner_reference_p=<optimized out>)
>      at /work/results_sc/src-patched/gcc/expr.cc:11552
> #6  0x0000000000bd8298 in expand_expr_real
> (exp=exp@entry=0xfffff65bf318, target=<optimized out>, tmode=<optimized
> out>, modifier=modifier@entry=EXPAND_NORMAL, alt_rtl=alt_rtl@entry=0x0,
>      inner_reference_p=inner_reference_p@entry=false) at
> /work/results_sc/src-patched/gcc/expr.cc:9628
> #7  0x0000000000a86328 in expand_expr (exp=0xfffff65bf318,
> target=<optimized out>, mode=<optimized out>, modifier=EXPAND_NORMAL) at
> /work/results_sc/src-patched/gcc/expr.h:323
> #8  expand_return (retval=0xfffff74c9a28) at
> /work/results_sc/src-patched/gcc/cfgexpand.cc:4172
> #9  expand_gimple_stmt_1 (stmt=0xfffff65a89a0) at
> /work/results_sc/src-patched/gcc/cfgexpand.cc:4281
> #10 expand_gimple_stmt (stmt=stmt@entry=0xfffff65a89a0) at
> /work/results_sc/src-patched/gcc/cfgexpand.cc:4390
> #11 0x0000000000a88938 in expand_gimple_basic_block (bb=<optimized out>,
> asan_epilog_seq=asan_epilog_seq@entry=0x0) at
> /work/results_sc/src-patched/gcc/cfgexpand.cc:6507
> --Type <RET> for more, q to quit, c to continue without paging--
> #12 0x0000000000a8a568 in (anonymous namespace)::pass_expand::execute
> (this=<optimized out>, fun=0xfffff6591000) at
> /work/results_sc/src-patched/gcc/cfgexpand.cc:7254
> #13 0x0000000000f7ce98 in execute_one_pass (pass=pass@entry=0x3297c70)
> at /work/results_sc/src-patched/gcc/passes.cc:2646
> #14 0x0000000000f7d8d4 in execute_pass_list_1 (pass=0x3297c70) at
> /work/results_sc/src-patched/gcc/passes.cc:2757
> #15 0x0000000000f7d948 in execute_pass_list (fn=<optimized out>,
> pass=<optimized out>) at /work/results_sc/src-patched/gcc/passes.cc:2768
> #16 0x0000000000aced24 in cgraph_node::expand (this=0xfffff6588aa0) at
> /work/results_sc/src-patched/gcc/context.h:49
> #17 cgraph_node::expand (this=0xfffff6588aa0) at
> /work/results_sc/src-patched/gcc/cgraphunit.cc:1827
> #18 0x0000000000ad0dc0 in expand_all_functions () at
> /work/results_sc/src-patched/gcc/cgraphunit.cc:2057
> #19 symbol_table::compile (this=this@entry=0xfffff7406000) at
> /work/results_sc/src-patched/gcc/cgraphunit.cc:2435
> #20 0x0000000000ad3a48 in symbol_table::compile (this=0xfffff7406000) at
> /work/results_sc/src-patched/gcc/cgraphunit.cc:2348
> #21 symbol_table::finalize_compilation_unit (this=0xfffff7406000) at
> /work/results_sc/src-patched/gcc/cgraphunit.cc:2626
> #22 0x00000000010bf96c in compile_file () at
> /work/results_sc/src-patched/gcc/toplev.cc:482
> #23 0x000000000086baac in do_compile () at
> /work/results_sc/src-patched/gcc/toplev.cc:2228
> #24 toplev::main (this=this@entry=0xfffffffff078, argc=<optimized out>,
> argc@entry=35, argv=<optimized out>, argv@entry=0xfffffffff1f8) at
> /work/results_sc/src-patched/gcc/toplev.cc:2392
> #25 0x000000000086d094 in main (argc=35, argv=0xfffffffff1f8) at
> /work/results_sc/src-patched/gcc/main.cc:39
> (gdb) up
> #1  0x0000000000be9c98 in store_constructor
> (exp=exp@entry=0xfffff6577e58, target=target@entry=0xfffff605d408,
> cleared=cleared@entry=0, size=..., reverse=reverse@entry=false)
>      at /work/results_sc/src-patched/gcc/expr.cc:8085
> 8085                    gcc_assert (icode != CODE_FOR_nothing);
>
> Context:
>
> 8080                  }
> 8081                else
> 8082                  {
> 8083                    /* Handle variable-length vector types.  */
> 8084                    icode = convert_optab_handler (vec_init_optab,
> mode, eltmode);
> 8085                    gcc_assert (icode != CODE_FOR_nothing);
> 8086                    const_n_elts = constant_lower_bound (n_elts);
> 8087                  }
> 8088
> 8089                if (const_n_elts && icode != CODE_FOR_nothing)
>
> As far as I can tell, store_constructor is designed to handle the case
> where vector is null. For example, it calls the store_constructor_field
> function per element instead of assigning values to RTVEC_ELT (vector,
> eltpos).

But right here it does

              vector = rtvec_alloc (const_n_elts);

so not sure what you mean with 'vector is null'.  Or is
constant_lower_bound == 0?

The only case that might be relevant is a {} CTOR, one without elements.  But
we should have special-paths for that - are they possibly not taken for VLA
vector modes?

I'll note that in general vector CTORs for BImode vectors that are not constant
are a red herring - totally inefficent - and we should avoid those at all cost.
But yes, the requirement outlined is that the target needs to support
vec_init with E_VNx16BImode, E_QImode.  If it does not the vectorizer
should not have created such CTOR.

Richard.


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