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

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

https://gcc.gnu.org/g:e71e5023ad9fe77a51f60f3609447b311e2515d6

commit r17-5898-ge71e5023ad9fe77a51f60f3609447b311e2515d6
Author: Kyrylo Tkachov <[email protected]>
Date:   Mon Nov 2 12:00:00 2026 +0100

    forwprop: do not splat an abnormal SSA name at a CONSTRUCTOR [PR128406]

    Since r16-5042 simplify_vector_constructor accepts a CONSTRUCTOR element
    that is a uniform vector and puts a splat of its scalar element at the
    place of the CONSTRUCTOR.  The splat is a new use of the scalar there.
    When the scalar is an SSA name that occurs in an abnormal PHI and is
    redefined before the CONSTRUCTOR, the live ranges of the two versions
    overlap and out-of-SSA fails.  For the new test at -O2 -mavx2, BB SLP
    makes a CONSTRUCTOR of vectors and forwprop4 changes

      _50 = {a0_25(ab), a1_26(ab)};
      _49 = {a2_27(ab), a3_28(ab)};
      _48 = {x_18(D)(ab), x_18(D)(ab)};
      k_31(ab) = _30;
      x_40(ab) = x_18(D)(ab) + 1.0e+0;
      _1 = {_50, _49, _48, _48};

    into

      x_40(ab) = x_18(D)(ab) + 1.0e+0;
      _35 = {x_18(D)(ab), x_18(D)(ab), x_18(D)(ab), x_18(D)(ab), ...};
      _36 = VEC_PERM_EXPR <v_24(D), _35, { 0, 1, 2, 3, 12, 13, 14, 15 }>;

    On aarch64 the NEON folds of vdup_n_s32, vget_high_s32 and vcombine_s32
    give forwprop1 the same kind of CONSTRUCTOR at -O1 (the new aarch64
    test).

    Do not use such an SSA name for a vector element.  A scalar element is
    already used at the CONSTRUCTOR, so its splat does not extend its live
    range.

    The new tests ICE on trunk: on x86_64 at -O2 with -mavx, -mavx2,
    -march=x86-64-v3 or -march=x86-64-v4, on aarch64 at -O1, -O2 and -O3.

    Bootstrapped and regression tested on aarch64-unknown-linux-gnu and
    x86_64-pc-linux-gnu.

    gcc/ChangeLog:

            PR tree-optimization/128406
            * tree-ssa-forwprop.cc (simplify_vector_constructor): Do not splat
            the element of a uniform vector if it is an SSA name that occurs in
            an abnormal PHI.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/128406
            * gcc.target/aarch64/pr128406.c: New test.
            * gcc.target/i386/pr128406.c: New test.

    Signed-off-by: Kyrylo Tkachov <[email protected]>

Reply via email to