[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 29/51] tcg/optimize: Use fold_masks_zs in fold_qemu_ld
From: |
Richard Henderson |
Subject: |
[PATCH v2 29/51] tcg/optimize: Use fold_masks_zs in fold_qemu_ld |
Date: |
Thu, 19 Dec 2024 20:10:41 -0800 |
Avoid the use of the OptContext slots.
Be careful not to call fold_masks_zs when the memory operation
is wide enough to require multiple outputs, so split into two
functions: fold_qemu_ld_1reg and fold_qemu_ld_2reg.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index da9c8c4669..b01929fccf 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -2127,24 +2127,33 @@ static bool fold_orc(OptContext *ctx, TCGOp *op)
return fold_masks_s(ctx, op, s_mask);
}
-static bool fold_qemu_ld(OptContext *ctx, TCGOp *op)
+static bool fold_qemu_ld_1reg(OptContext *ctx, TCGOp *op)
{
const TCGOpDef *def = &tcg_op_defs[op->opc];
MemOpIdx oi = op->args[def->nb_oargs + def->nb_iargs];
MemOp mop = get_memop(oi);
int width = 8 * memop_size(mop);
+ uint64_t z_mask = -1, s_mask = 0;
if (width < 64) {
- ctx->s_mask = MAKE_64BIT_MASK(width, 64 - width);
+ s_mask = MAKE_64BIT_MASK(width, 64 - width);
if (!(mop & MO_SIGN)) {
- ctx->z_mask = MAKE_64BIT_MASK(0, width);
- ctx->s_mask <<= 1;
+ z_mask = MAKE_64BIT_MASK(0, width);
+ s_mask <<= 1;
}
}
/* Opcodes that touch guest memory stop the mb optimization. */
ctx->prev_mb = NULL;
- return false;
+
+ return fold_masks_zs(ctx, op, z_mask, s_mask);
+}
+
+static bool fold_qemu_ld_2reg(OptContext *ctx, TCGOp *op)
+{
+ /* Opcodes that touch guest memory stop the mb optimization. */
+ ctx->prev_mb = NULL;
+ return finish_folding(ctx, op);
}
static bool fold_qemu_st(OptContext *ctx, TCGOp *op)
@@ -3033,11 +3042,18 @@ void tcg_optimize(TCGContext *s)
break;
case INDEX_op_qemu_ld_a32_i32:
case INDEX_op_qemu_ld_a64_i32:
+ done = fold_qemu_ld_1reg(&ctx, op);
+ break;
case INDEX_op_qemu_ld_a32_i64:
case INDEX_op_qemu_ld_a64_i64:
+ if (TCG_TARGET_REG_BITS == 64) {
+ done = fold_qemu_ld_1reg(&ctx, op);
+ break;
+ }
+ QEMU_FALLTHROUGH;
case INDEX_op_qemu_ld_a32_i128:
case INDEX_op_qemu_ld_a64_i128:
- done = fold_qemu_ld(&ctx, op);
+ done = fold_qemu_ld_2reg(&ctx, op);
break;
case INDEX_op_qemu_st8_a32_i32:
case INDEX_op_qemu_st8_a64_i32:
--
2.43.0
- [PATCH v2 21/51] tcg/optimize: Use fold_masks_zs in fold_movcond, (continued)
- [PATCH v2 21/51] tcg/optimize: Use fold_masks_zs in fold_movcond, Richard Henderson, 2024/12/19
- [PATCH v2 32/51] tcg/optimize: Distinguish simplification in fold_setcond_zmask, Richard Henderson, 2024/12/19
- [PATCH v2 19/51] tcg/optimize: Use fold_masks_zs in fold_exts, Richard Henderson, 2024/12/19
- [PATCH v2 24/51] tcg/optimize: Use fold_masks_z in fold_neg_no_const, Richard Henderson, 2024/12/19
- [PATCH v2 10/51] tcg/optimize: Use fold_masks_zs in fold_count_zeros, Richard Henderson, 2024/12/19
- [PATCH v2 18/51] tcg/optimize: Use finish_folding in fold_extract2, Richard Henderson, 2024/12/19
- [PATCH v2 27/51] tcg/optimize: Use fold_masks_zs in fold_or, Richard Henderson, 2024/12/19
- [PATCH v2 26/51] tcg/optimize: Use fold_masks_s in fold_not, Richard Henderson, 2024/12/19
- [PATCH v2 30/51] tcg/optimize: Return true from fold_qemu_st, fold_tcg_st, Richard Henderson, 2024/12/19
- [PATCH v2 29/51] tcg/optimize: Use fold_masks_zs in fold_qemu_ld,
Richard Henderson <=
- [PATCH v2 31/51] tcg/optimize: Use finish_folding in fold_remainder, Richard Henderson, 2024/12/19
- [PATCH v2 33/51] tcg/optimize: Use fold_masks_z in fold_setcond, Richard Henderson, 2024/12/19
- [PATCH v2 35/51] tcg/optimize: Fix sign mask in fold_negsetcond, Richard Henderson, 2024/12/19
- [PATCH v2 37/51] tcg/optimize: Use finish_folding in fold_cmp_vec, Richard Henderson, 2024/12/19
- [PATCH v2 38/51] tcg/optimize: Use finish_folding in fold_cmpsel_vec, Richard Henderson, 2024/12/19
- [PATCH v2 34/51] tcg/optimize: Use fold_masks_s in fold_negsetcond, Richard Henderson, 2024/12/19
- [PATCH v2 36/51] tcg/optimize: Use fold_masks_z in fold_setcond2, Richard Henderson, 2024/12/19
- [PATCH v2 25/51] tcg/optimize: Use fold_masks_s in fold_nor, Richard Henderson, 2024/12/19