https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124142

--- Comment #8 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:0383e6c398a0636c54209ce5822fd4fd43e9a99f

commit r16-7762-g0383e6c398a0636c54209ce5822fd4fd43e9a99f
Author: Tamar Christina <[email protected]>
Date:   Fri Feb 27 14:21:36 2026 +0000

    vect: enforce trapping math checks when early breaks [PR124142]

    The loop

    void
    __attribute__((noipa))
    bug (int f, int *w, int l)
    {
      int i;
      for (i = 0; i < l; ++i)
        while (f % w[i]) w[i]--;
    }

    is an uncounted loop which performs a trapping operation during
vectorization.
    Normally the vectorizer doesn't stop vectorization if the operation can't
be
    masked (though ifcvt does).

    For Early breaks however this is unsafe as we are introducing a trap where
the
    original scalar code may not have.

    Some tests now fail to vectorize (including some tsvc ones) which I could
have
    xfail'ed but instead decided to add -fno-trapping-math just to get the
    additional coverage they provide.

    gcc/ChangeLog:

            PR tree-optimization/124142
            * tree-vect-data-refs.cc (vect_analyze_early_break_dependences):
            For early break require masking when operation can trap.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/124142
            * gcc.dg/vect/tsvc/vect-tsvc-s481.c: Add -fno-trapping-math.
            * gcc.dg/vect/tsvc/vect-tsvc-s332.c: Likewise.
            * gcc.dg/vect/tsvc/vect-tsvc-s482.c: Likewise.
            * gcc.dg/vect/vect-early-break_61.c: Likewise.
            * gcc.target/aarch64/vect-early-break-cbranch_3.c: Likewise.
            * gcc.dg/vect/vect-early-break_143-pr124142.c: New test

Reply via email to