From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PATCH 4/4] tcg: Eliminate duplicate env store operations
Date: Wed, 30 Aug 2023 19:57:29 -0700 [thread overview]
Message-ID: <20230831025729.1194388-5-richard.henderson@linaro.org> (raw)
In-Reply-To: <20230831025729.1194388-1-richard.henderson@linaro.org>
Notice when a constant is stored to the same location twice.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 51c4c61b9f..6efc08f593 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -2251,6 +2251,19 @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
src = arg_temp(op->args[0]);
ofs = op->args[2];
type = ctx->type;
+
+ /*
+ * Eliminate duplicate stores of a constant.
+ * This happens frequently when the target ISA zero-extends.
+ */
+ if (ts_is_const(src)) {
+ TCGTemp *prev = find_mem_copy_for(ctx, type, ofs);
+ if (src == prev) {
+ tcg_op_remove(ctx->tcg, op);
+ return true;
+ }
+ }
+
last = ofs + tcg_type_size(type) - 1;
remove_mem_copy_in(ctx, ofs, last);
record_mem_copy(ctx, type, src, ofs, last);
--
2.34.1
next prev parent reply other threads:[~2023-08-31 2:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 2:57 [PATCH 0/4] tcg: Optimize loads and stores to env Richard Henderson
2023-08-31 2:57 ` [PATCH 1/4] tcg: Don't free vector results Richard Henderson
2023-08-31 2:57 ` [PATCH 2/4] tcg/optimize: Pipe OptContext into reset_ts Richard Henderson
2023-10-02 12:37 ` Philippe Mathieu-Daudé
2023-08-31 2:57 ` [PATCH 3/4] tcg: Optimize env memory operations Richard Henderson
2023-08-31 2:57 ` Richard Henderson [this message]
2023-09-28 22:45 ` [PATCH 0/4] tcg: Optimize loads and stores to env Richard Henderson
2023-10-13 17:40 ` Richard Henderson
2023-10-16 3:01 ` gaosong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230831025729.1194388-5-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).