https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128662
--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Uros Bizjak <[email protected]>: https://gcc.gnu.org/g:9844856b32f318381ba0ded6da2ed2d548b778a7 commit r17-6230-g9844856b32f318381ba0ded6da2ed2d548b778a7 Author: Uros Bizjak <[email protected]> Date: Thu Nov 12 11:37:24 2026 +0100 i386: Avoid false dependency for BSR [PR128662] BSR leaves its destination unmodified when the source is zero, so the hardware treats the destination as an input. This creates a false dependency on the previous value of the destination register, which can delay BSR until that value is available. Clear the destination before BSR via post-epilogue splitters when the destination is not used by the source, controlled by the new X86_TUNE_AVOID_FALSE_DEP_FOR_BSR tuning. The tuning is enabled for processors where BSR is a single uop and the dependency is longer than its throughput cost, and for generic. Disable the new tuning in pr78103-*.c, which check the exact BSR code sequence generated for generic tuning. Assisted-by: Claude Sonnet 5.5 PR target/128662 gcc/ChangeLog: * config/i386/i386.h (TARGET_AVOID_FALSE_DEP_FOR_BSR): New. * config/i386/x86-tune.def (X86_TUNE_AVOID_FALSE_DEP_FOR_BSR): New tuning. * config/i386/i386.md (bsr_rex64): Convert to define_insn_and_split. Split to *bsr_rex64_falsedep when TARGET_AVOID_FALSE_DEP_FOR_BSR is set and the destination is not mentioned in the source. (bsr_rex64_1): Ditto. Split to *bsr_rex64_1_falsedep. (bsr_rex64_1_zext): Ditto. Split to *bsr_rex64_1_zext_falsedep. (bsr): Ditto. Split to *bsr_falsedep. (bsr_1): Ditto. Split to *bsr_1_falsedep. (bsr_zext_1): Ditto. Split to *bsr_zext_1_falsedep. (*bsr_rex64_falsedep, *bsr_rex64_1_falsedep) (*bsr_rex64_1_zext_falsedep, *bsr_falsedep, *bsr_1_falsedep) (*bsr_zext_1_falsedep): New insns. gcc/testsuite/ChangeLog: * gcc.target/i386/pr128662.c: New test. * gcc.target/i386/pr78103-1.c (dg-options): Add -mtune-ctrl=^avoid_false_dep_for_bsr. * gcc.target/i386/pr78103-2.c: Ditto. * gcc.target/i386/pr78103-3.c: Ditto.
