From: Richard Henderson Date: Thu, 24 Aug 2023 06:13:06 +0000 (-0700) Subject: tcg: Eliminate duplicate env store operations X-Git-Tag: pull-xenfv.for-upstream-20231107~16^2~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3eaadaeb4ee9cc6a1267882b3e31c893cd99bb9e;p=users%2Fdwmw2%2Fqemu.git tcg: Eliminate duplicate env store operations Notice when a constant is stored to the same location twice. Reviewed-by: Song Gao Signed-off-by: Richard Henderson --- diff --git a/tcg/optimize.c b/tcg/optimize.c index b32ef0be0f..a4fe9ee9bb 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -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);