https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119160
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Philipp Tomsich <ptoms...@gcc.gnu.org>: https://gcc.gnu.org/g:7e628ff49f7f890d5337369d7b4f8e21a1f17029 commit r16-15-g7e628ff49f7f890d5337369d7b4f8e21a1f17029 Author: kelefth <konstantinos.elefther...@vrull.eu> Date: Thu Mar 13 11:49:39 2025 +0100 avoid-store-forwarding: Fix reg init on load-elimination [PR119160] In the case that we are eliminating the load instruction, we use zero_extend for the initialization of the base register for the zero-offset store. This causes issues when the store and the load use the same mode, as we are trying to generate a zero_extend with the same inner and outer modes. This patch fixes the issue by zero-extending the value stored in the base register only when the load's mode is wider than the store's mode. PR rtl-optimization/119160 gcc/ChangeLog: * avoid-store-forwarding.cc (process_store_forwarding): Zero-extend the value stored in the base register, in case of load-elimination, only when the mode of the destination is wider. gcc/testsuite/ChangeLog: * gcc.dg/pr119160.c: New test.