[Bug tree-optimization/126369] VLA versioning can generate unreachable code

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]> Tue, 04 Aug 2026 14:22:29 +0000
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126369

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <[email protected]=
>:

https://gcc.gnu.org/g:504b4763fd5080d078f0a7fe55501b003a079206

commit r17-2935-g504b4763fd5080d078f0a7fe55501b003a079206
Author: Tamar Christina <[email protected]>
Date:   Tue Aug 4 15:21:54 2026 +0100

    vect: move check for safe speculative reads for inbound access [PR12636=
9]

    It turns out that the DR_SCALAR_KNOWN_BOUNDS check which checks to see =
that
even
    if misaligned but all scalar accesses are in bounds of a known fixed si=
ze
array
    then we're OK and just need to force masking.

    The loop it was placed in would exit early after the first misaligned
access and
    so when you have more than one data access in the loop it wouldn't mark=
 the
    other accesses as safe to speculate.

    This moves it to its own loop.

    gcc/ChangeLog:

            PR tree-optimization/126369
            * tree-vect-data-refs.cc (vect_enhance_data_refs_alignment): Mo=
ve
            DR_SCALAR_KNOWN_BOUNDS safe speculation check.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/126369
            * gcc.target/aarch64/sve/peeled4.c: New test.=