https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116037
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <l...@gcc.gnu.org>: https://gcc.gnu.org/g:679086172b84be18c55fdbb9cda7e97806e7c083 commit r15-2275-g679086172b84be18c55fdbb9cda7e97806e7c083 Author: Jeff Law <j...@ventanamicro.com> Date: Wed Jul 24 11:16:26 2024 -0600 [rtl-optimization/116037] Explicitly track if a destination was skipped in ext-dce So this has been in the hopper since the first bugs were reported against ext-dce. It'd been holding off committing as I was finding other issues in terms of correctness of live computations. There's still problems in that space, but I think it's time to push this chunk forward. I'm marking it as 116037, but it may impact other bugs. This patch starts explicitly tracking if set processing skipped a destination, which can happen for wide modes (TI+), vectors, certain subregs, etc. This is computed during ext_dce_set_processing. During use processing we use that flag to determine reliably if we need to make the inputs fully live and to avoid even trying to eliminate an extension if we skipped output processing. While testing this I found that a recent change to fix cases where we had two subreg input operands mucked up the code to make things like a shift/rotate count fully live. So that goof has been fixed. Bootstrapped and regression tested on x86. Most, but not all, of these changes have also been tested on the crosses. Pushing to the trunk. I'm not including it in this patch but I'm poking at converting this code to use note_uses/note_stores to make it more maintainable. The SUBREG and STRICT_LOW_PART handling of note_stores is problematical, but I think it's solvable. I haven't tried a conversion to note_uses yet. PR rtl-optimization/116037 gcc/ * ext-dce.cc (ext_dce_process_sets): Note if we ever skip a dest and return that info explicitly. (ext_dce_process_uses): If a set was skipped, then consider all bits in every input as live. Do not try to optimize away an extension if we skipped processing a destination in the same insn. Restore code to make shift/rotate count fully live. (ext_dce_process_bb): Handle API changes for ext_dce_process_sets. gcc/testsuite/ * gcc.dg/torture/pr116037.c: New test