https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126556
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Igor Shevlyakov <[email protected]>: https://gcc.gnu.org/g:032b844694e56780ac3ac8d5f2ba5cff7ee33e94 commit r17-6822-g032b844694e56780ac3ac8d5f2ba5cff7ee33e94 Author: Igor Shevlyakov <[email protected]> Date: Wed Nov 25 13:16:35 2026 -0800 combine: Use subst to fold a constant comparison into its CC user [PR126556] When simplify_set finds that the comparison setting a CC register has a constant result, it replaced the comparison in the CC user with the constant and then simplified the SET_SRC of the user. When the comparison is the operand of a ZERO_EXTEND, as in aarch64's *cstoresi_insn_uxtw, the first step creates (zero_extend:DI (const_int 0)), and substituting the simplified source then fails the assertion in do_SUBST against such RTL. Do the replacement with subst instead, which folds an extension of a constant while the mode of its operand is still known and then simplifies the result. simplify_set can run inside the subst calls of try_combine, which count their replacements in n_occurrences, so save and restore it around the nested call. Assisted-by: Claude Opus 5.5 PR rtl-optimization/126556 gcc/ChangeLog: * combine.cc (simplify_set): Use subst to replace a comparison with a constant result in the CC user, preserving n_occurrences. gcc/testsuite/ChangeLog: * gcc.dg/torture/pr126556.c: New test. Signed-off-by: Igor Shevlyakov <[email protected]>
