]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tcg: Eliminate duplicate env store operations
authorRichard Henderson <richard.henderson@linaro.org>
Thu, 24 Aug 2023 06:13:06 +0000 (23:13 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Mon, 6 Nov 2023 16:27:21 +0000 (08:27 -0800)
Notice when a constant is stored to the same location twice.

Reviewed-by: Song Gao <gaosong@loongson.cn>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
tcg/optimize.c

index b32ef0be0f9fcf78e9bd227a160a824ad1617322..a4fe9ee9bb70ba6fbf46d5496b5b76a1287d5157 100644 (file)
@@ -2269,6 +2269,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);