aboutsummaryrefslogtreecommitdiff
path: root/gcc/avoid-store-forwarding.cc
diff options
context:
space:
mode:
authorkelefth <konstantinos.eleftheriou@vrull.eu>2024-12-16 14:36:59 +0100
committerPhilipp Tomsich <philipp.tomsich@vrull.eu>2024-12-30 12:55:41 +0100
commitc86e1c54c6f8771d08a8c070717b80607f990f8a (patch)
tree3fe980c9d967257410297d3c4cb1ea6a2006061a /gcc/avoid-store-forwarding.cc
parent8a4e57e6bc63eba78e5f3b0090e58d48a95dcbc7 (diff)
downloadgcc-c86e1c54c6f8771d08a8c070717b80607f990f8a.zip
gcc-c86e1c54c6f8771d08a8c070717b80607f990f8a.tar.gz
gcc-c86e1c54c6f8771d08a8c070717b80607f990f8a.tar.bz2
avoid-store-forwarding: fix reg init on load-eliminiation [PR117835]
During the initialization of the base register for the zero-offset store, in the case that we are eliminating the load, we used a paradoxical subreg assuming that we don't care about the higher bits of the register. This led to writing wrong values when we were not updating the whole register. This patch fixes the issue by zero-extending the value stored in the base register instead of using a paradoxical subreg. Bootstrapped/regtested on x86 and AArch64. PR rtl-optimization/117835 PR rtl-optimization/117872 gcc/ChangeLog: * avoid-store-forwarding.cc (store_forwarding_analyzer::process_store_forwarding): Zero-extend the value stored in the base register instead of using a paradoxical subreg. gcc/testsuite/ChangeLog: * gcc.target/i386/pr117835.c: New test.
Diffstat (limited to 'gcc/avoid-store-forwarding.cc')
-rw-r--r--gcc/avoid-store-forwarding.cc6
1 files changed, 1 insertions, 5 deletions
diff --git a/gcc/avoid-store-forwarding.cc b/gcc/avoid-store-forwarding.cc
index 1b8c35b..fa83e10 100644
--- a/gcc/avoid-store-forwarding.cc
+++ b/gcc/avoid-store-forwarding.cc
@@ -238,11 +238,7 @@ process_store_forwarding (vec<store_fwd_info> &stores, rtx_insn *load_insn,
{
start_sequence ();
- /* We can use a paradoxical subreg to force this to a wider mode, as
- the only use will be inserting the bits (i.e., we don't care about
- the value of the higher bits). */
- rtx ext0 = lowpart_subreg (GET_MODE (dest), it->mov_reg,
- GET_MODE (it->mov_reg));
+ rtx ext0 = gen_rtx_ZERO_EXTEND (GET_MODE (dest), it->mov_reg);
if (ext0)
{
rtx_insn *move0 = emit_move_insn (dest, ext0);