Skip to content

Commit

Permalink
tcg: Eliminate duplicate env store operations
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rth7680 committed Nov 6, 2023
1 parent ab84dc3 commit 3eaadae
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tcg/optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 3eaadae

Please sign in to comment.