On Thu, 23 Oct 2025, Alex Coplan wrote:

> Hi,
> 
> On 23/10/2025 12:56, Richard Biener wrote:
> > The following fixes a segfault that appeared with a patch applying
> > additional permutes to a reduction SLP instance root.
> 
> I just ran into an ICE which looks to be fixed by this patch, would a
> reduced testcase be useful?  I can share one if so.  I was surprised to see
> there wasn't a PR or test for this patch.

Sure.  The testcase that ICEd for me (with another patch not pushed)
was existing in the fortran testsuite.

Richard.

> The stacktrace I saw was:
> 
> ./xgcc -B . -c t.c -S -o /dev/null -O3
> during GIMPLE pass: vect
> t.c: In function ‘f’:
> t.c:3:7: internal compiler error: Segmentation fault
>     3 | _Bool f() {
>       |       ^
> 0x25146e7 internal_error(char const*, ...)
>         /home/alecop01/toolchain/src/gcc/gcc/diagnostic-global-context.cc:787
> 0x113a3a3 crash_signal
>         /home/alecop01/toolchain/src/gcc/gcc/toplev.cc:323
> 0x14b45ac vect_analyze_loop_2
>         /home/alecop01/toolchain/src/gcc/gcc/tree-vect-loop.cc:2601
> 0x14b51c7 vect_analyze_loop_1
>         /home/alecop01/toolchain/src/gcc/gcc/tree-vect-loop.cc:2790
> 0x14b5c07 vect_analyze_loop(loop*, gimple*, vec_info_shared*)
>         /home/alecop01/toolchain/src/gcc/gcc/tree-vect-loop.cc:2971
> 0x15419ab try_vectorize_loop_1
>         /home/alecop01/toolchain/src/gcc/gcc/tree-vectorizer.cc:1096
> 0x1541ee7 try_vectorize_loop
>         /home/alecop01/toolchain/src/gcc/gcc/tree-vectorizer.cc:1215
> 0x1542157 execute
>         /home/alecop01/toolchain/src/gcc/gcc/tree-vectorizer.cc:1331
> Please submit a full bug report, with preprocessed source (by using 
> -freport-bug).
> Please include the complete backtrace with any bug report.
> See <https://gcc.gnu.org/bugs/> for instructions.
> 
> Thanks,
> Alex
> 
> > 
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
> > 
> >     * tree-vect-loop.cc (vect_analyze_loop_2): Deal with NULL
> >     element in SLP_TREE_SCALAR_STMTS.
> > ---
> >  gcc/tree-vect-loop.cc | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> > index 77c9e15601b..7bb1c6baee8 100644
> > --- a/gcc/tree-vect-loop.cc
> > +++ b/gcc/tree-vect-loop.cc
> > @@ -2598,7 +2598,7 @@ again:
> >  
> >        stmt_vec_info vinfo;
> >        vinfo = SLP_TREE_SCALAR_STMTS (SLP_INSTANCE_TREE (instance))[0];
> > -      if (! STMT_VINFO_GROUPED_ACCESS (vinfo))
> > +      if (!vinfo || !STMT_VINFO_GROUPED_ACCESS (vinfo))
> >     continue;
> >        vinfo = DR_GROUP_FIRST_ELEMENT (vinfo);
> >        unsigned int size = DR_GROUP_SIZE (vinfo);
> > -- 
> > 2.51.0
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

Reply via email to