Ok, thanks. Filed as PR 126225 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126225
Cem On Sun, Jul 12, 2026 at 12:52 AM Sam James <[email protected]> wrote: > Cem Akgok <[email protected]> writes: > > > vectorizable_induction reduces the number of generated SLP induction > > IVs when group_size is evenly divisible by const_nunits. Existing > > code did this without checking that the vector chunks being folded have > > the same scalar initial values and steps with their counterparts. > > If either differed, reusing an earlier IV produced wrong code. > > > > Compute the unreduced IV count first and use the reduced count only when > > each folded chunk has initial values and steps equal to its corresponding > > earlier chunk. When initial values come from an SLP node and their scalar > > values are unavailable, conservatively keep the unreduced count. > > > > Added tests for mismatched initial values, mismatched steps, and a valid > > multi-IV reuse pattern. > > > > gcc/ChangeLog: > > > > * tree-vect-loop.cc (vect_slp_induction_reuse_p): New function. > > (vectorizable_induction): Validate SLP induction IV reuse. Reuse > > generated IVs cyclically when filling the SLP group. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.dg/vect/vect-iv-12.c: New test. > > * gcc.dg/vect/vect-iv-13.c: New test. > > * gcc.dg/vect/vect-iv-14.c: New test. > > > > Signed-off-by: Cem Akgok <[email protected]> > > --- > > Godbolt: https://godbolt.org/z/Mbohx7sEn > > Wrong code at -O2. > > All major versions from 11 to trunk affected. (11 miscompiles at -O3 > only) > > Compiles correctly with -fno-tree-loop-vectorize. > > Can you file a bug report for this too please? Any fix will need > backporting. > > sam >
