[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 01/51] tcg/optimize: Split out finish_bb, finish_ebb
From: |
Richard Henderson |
Subject: |
[PATCH v2 01/51] tcg/optimize: Split out finish_bb, finish_ebb |
Date: |
Thu, 19 Dec 2024 20:10:13 -0800 |
Call them directly from the opcode switch statement in tcg_optimize,
rather than in finish_folding based on opcode flags. Adjust folding
of conditional branches to match.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 47 +++++++++++++++++++++++++++++++----------------
1 file changed, 31 insertions(+), 16 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index e9ef16b3c6..453e8c43bd 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -964,24 +964,25 @@ static void copy_propagate(OptContext *ctx, TCGOp *op,
}
}
+static void finish_bb(OptContext *ctx)
+{
+ /* We only optimize memory barriers across basic blocks. */
+ ctx->prev_mb = NULL;
+}
+
+static void finish_ebb(OptContext *ctx)
+{
+ finish_bb(ctx);
+ /* We only optimize across extended basic blocks. */
+ memset(&ctx->temps_used, 0, sizeof(ctx->temps_used));
+ remove_mem_copy_all(ctx);
+}
+
static void finish_folding(OptContext *ctx, TCGOp *op)
{
const TCGOpDef *def = &tcg_op_defs[op->opc];
int i, nb_oargs;
- /*
- * We only optimize extended basic blocks. If the opcode ends a BB
- * and is not a conditional branch, reset all temp data.
- */
- if (def->flags & TCG_OPF_BB_END) {
- ctx->prev_mb = NULL;
- if (!(def->flags & TCG_OPF_COND_BRANCH)) {
- memset(&ctx->temps_used, 0, sizeof(ctx->temps_used));
- remove_mem_copy_all(ctx);
- }
- return;
- }
-
nb_oargs = def->nb_oargs;
for (i = 0; i < nb_oargs; i++) {
TCGTemp *ts = arg_temp(op->args[i]);
@@ -1351,8 +1352,11 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op)
if (i > 0) {
op->opc = INDEX_op_br;
op->args[0] = op->args[3];
+ finish_ebb(ctx);
+ } else {
+ finish_bb(ctx);
}
- return false;
+ return true;
}
static bool fold_brcond2(OptContext *ctx, TCGOp *op)
@@ -1443,9 +1447,12 @@ static bool fold_brcond2(OptContext *ctx, TCGOp *op)
}
op->opc = INDEX_op_br;
op->args[0] = label;
- break;
+ finish_ebb(ctx);
+ return true;
}
- return false;
+
+ finish_bb(ctx);
+ return true;
}
static bool fold_bswap(OptContext *ctx, TCGOp *op)
@@ -3037,6 +3044,14 @@ void tcg_optimize(TCGContext *s)
CASE_OP_32_64_VEC(xor):
done = fold_xor(&ctx, op);
break;
+ case INDEX_op_set_label:
+ case INDEX_op_br:
+ case INDEX_op_exit_tb:
+ case INDEX_op_goto_tb:
+ case INDEX_op_goto_ptr:
+ finish_ebb(&ctx);
+ done = true;
+ break;
default:
break;
}
--
2.43.0
- [PATCH v2 00/51] tcg: Remove in-flight mask data from OptContext, Richard Henderson, 2024/12/19
- [PATCH v2 04/51] tcg/optimize: Split out fold_masks_zs, Richard Henderson, 2024/12/19
- [PATCH v2 03/51] tcg/optimize: Copy mask writeback to fold_masks, Richard Henderson, 2024/12/19
- [PATCH v2 02/51] tcg/optimize: Split out fold_affected_mask, Richard Henderson, 2024/12/19
- [PATCH v2 01/51] tcg/optimize: Split out finish_bb, finish_ebb,
Richard Henderson <=
- [PATCH v2 05/51] tcg/optimize: Augment s_mask from z_mask in fold_masks_zs, Richard Henderson, 2024/12/19
- [PATCH v2 06/51] tcg/optimize: Use finish_folding in fold_add, fold_add_vec, fold_addsub2, Richard Henderson, 2024/12/19
- [PATCH v2 07/51] tcg/optimize: Use fold_masks_zs in fold_and, Richard Henderson, 2024/12/19
- [PATCH v2 11/51] tcg/optimize: Use fold_masks_z in fold_ctpop, Richard Henderson, 2024/12/19
- [PATCH v2 08/51] tcg/optimize: Use fold_masks_zs in fold_andc, Richard Henderson, 2024/12/19
- [PATCH v2 12/51] tcg/optimize: Use fold_and and fold_masks_z in fold_deposit, Richard Henderson, 2024/12/19
- [PATCH v2 09/51] tcg/optimize: Use fold_masks_zs in fold_bswap, Richard Henderson, 2024/12/19
- [PATCH v2 14/51] tcg/optimize: Use finish_folding in fold_divide, Richard Henderson, 2024/12/19
- [PATCH v2 17/51] tcg/optimize: Use fold_masks_z in fold_extract, Richard Henderson, 2024/12/19