https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128271
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-14 branch has been updated by Uros Bizjak <[email protected]>: https://gcc.gnu.org/g:13d3404441a08ea27afe8e77a4aa285d37274002 commit r14-12985-g13d3404441a08ea27afe8e77a4aa285d37274002 Author: Uros Bizjak <[email protected]> Date: Thu Oct 29 14:53:39 2026 +0100 i386: Model memory and flags effects of CET shadow stack insns [PR128271] The rstorssp, wrss, wruss and clrssbsy patterns described their memory operand as an input of an UNSPEC_VOLATILE, although all four modify it. UNSPEC_VOLATILE does not prevent passes such as cse1 from reusing a memory value loaded before the insn, so a load after wrssq could be CSE'd with an earlier one and return a stale value. Describe the memory operand as set by the insn: wrss and wruss only store, while rstorssp and clrssbsy read and modify the token, so use a "+m" operand with match_dup. Additionally, clrssbsy clobbers the flags, but the pattern did not say so, so compare-elim could reuse flags computed before the insn. Add a clobber of FLAGS_REG. Also use the "* return" output template form for nop_endbr. PR target/128271 gcc/ChangeLog: * config/i386/i386.md (rstorssp): Model the memory operand as read and modified by the insn. (clrssbsy): Ditto. Clobber FLAGS_REG. (@wrss<mode>, @wruss<mode>): Model the memory operand as set by the insn. gcc/testsuite/ChangeLog: * gcc.target/i386/pr128271-1.c: New test. * gcc.target/i386/pr128271-2.c: Ditto. (cherry picked from commit a8b927a09c79314624a8c594a5ed0ad12d7f7513)
