https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128013
--- Comment #9 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:e9a08d39562f585346818a6edc8c28b05c417328 commit r17-5810-ge9a08d39562f585346818a6edc8c28b05c417328 Author: Kyrylo Tkachov <[email protected]> Date: Thu Oct 15 20:58:19 2026 +0200 forwprop: do not fold a CONSTRUCTOR into an abnormal PHI vector [PR128013] simplify_vector_constructor replaces a CONSTRUCTOR of BIT_FIELD_REFs of one or two vectors by a permutation of these vectors, or by the vector itself, at the place of the CONSTRUCTOR. This extends the live ranges of the vectors. When such a vector 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 second testcase of PR128013 at -O1, forwprop1 changes <bb 2>: a0_10 = BIT_FIELD_REF <v_9(D)(ab), 32, 0>; ... a3_13 = BIT_FIELD_REF <v_9(D)(ab), 32, 96>; bar (); <bb 3>: ... v_16(ab) = _2; _3 = {a0_10, a1_11, a2_12, a3_13}; *out_17(D) = _3; into v_16(ab) = _2; _3 = v_9(D)(ab); *out_17(D) = _3; Do not use an SSA name that occurs in an abnormal PHI there. gimple_simplify has the same rule for the statements that it makes (see maybe_push_res_to_seq). For the same reason, the fix for PR125502 stops optimize_vector_load from moving the definition of such an SSA name. The new test ICEs on trunk on aarch64 and x86_64 at -O1 and above. On aarch64 the patch changes the assembly of one file in about 18600 files of gcc.dg, gcc.dg/torture, gcc.dg/tree-ssa, gcc.c-torture, gcc.dg/vect and g++.dg/vect, at -O3 and at -O2 -ftree-vectorize -fno-vect-cost-model: f2 of bb-slp-pr128013.c builds the vector of the lanes of v again instead of using v (6 more instructions). At -O2 -ftree-vectorize -fno-vect-cost-model, f1 also does this (8 more instructions). Bootstrapped and regression tested on aarch64-unknown-linux-gnu and x86_64-pc-linux-gnu. gcc/ChangeLog: PR tree-optimization/128013 * tree-ssa-forwprop.cc (simplify_vector_constructor): Do not use an SSA name that occurs in an abnormal PHI. gcc/testsuite/ChangeLog: PR tree-optimization/128013 * gcc.dg/torture/pr128013.c: New test. Signed-off-by: Kyrylo Tkachov <[email protected]>
