[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 17/60] tcg/optimize: Split out finish_folding
From: |
Richard Henderson |
Subject: |
[PULL v2 17/60] tcg/optimize: Split out finish_folding |
Date: |
Thu, 28 Oct 2021 21:32:46 -0700 |
Copy z_mask into OptContext, for writeback to the
first output within the new function.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 49 +++++++++++++++++++++++++++++++++----------------
1 file changed, 33 insertions(+), 16 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 066e635f73..368457f4a2 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -48,6 +48,9 @@ typedef struct OptContext {
TCGContext *tcg;
TCGOp *prev_mb;
TCGTempSet temps_used;
+
+ /* In flight values from optimization. */
+ uint64_t z_mask;
} OptContext;
static inline TempOptInfo *ts_info(TCGTemp *ts)
@@ -629,6 +632,34 @@ static void copy_propagate(OptContext *ctx, TCGOp *op,
}
}
+static void finish_folding(OptContext *ctx, TCGOp *op)
+{
+ const TCGOpDef *def = &tcg_op_defs[op->opc];
+ int i, nb_oargs;
+
+ /*
+ * For an opcode that ends a BB, reset all temp data.
+ * We do no cross-BB optimization.
+ */
+ if (def->flags & TCG_OPF_BB_END) {
+ memset(&ctx->temps_used, 0, sizeof(ctx->temps_used));
+ ctx->prev_mb = NULL;
+ return;
+ }
+
+ nb_oargs = def->nb_oargs;
+ for (i = 0; i < nb_oargs; i++) {
+ reset_temp(op->args[i]);
+ /*
+ * Save the corresponding known-zero bits mask for the
+ * first output argument (only one supported so far).
+ */
+ if (i == 0) {
+ arg_info(op->args[i])->z_mask = ctx->z_mask;
+ }
+ }
+}
+
static bool fold_call(OptContext *ctx, TCGOp *op)
{
TCGContext *s = ctx->tcg;
@@ -1122,6 +1153,7 @@ void tcg_optimize(TCGContext *s)
partmask &= 0xffffffffu;
affected &= 0xffffffffu;
}
+ ctx.z_mask = z_mask;
if (partmask == 0) {
tcg_opt_gen_movi(&ctx, op, op->args[0], 0);
@@ -1570,22 +1602,7 @@ void tcg_optimize(TCGContext *s)
break;
}
- /* Some of the folding above can change opc. */
- opc = op->opc;
- def = &tcg_op_defs[opc];
- if (def->flags & TCG_OPF_BB_END) {
- memset(&ctx.temps_used, 0, sizeof(ctx.temps_used));
- } else {
- int nb_oargs = def->nb_oargs;
- for (i = 0; i < nb_oargs; i++) {
- reset_temp(op->args[i]);
- /* Save the corresponding known-zero bits mask for the
- first output argument (only one supported so far). */
- if (i == 0) {
- arg_info(op->args[i])->z_mask = z_mask;
- }
- }
- }
+ finish_folding(&ctx, op);
/* Eliminate duplicate and redundant fence instructions. */
if (ctx.prev_mb) {
--
2.25.1
- [PULL v2 03/60] host-utils: move udiv_qrnnd() to host-utils, (continued)
- [PULL v2 03/60] host-utils: move udiv_qrnnd() to host-utils, Richard Henderson, 2021/10/29
- [PULL v2 05/60] host-utils: add unit tests for divu128/divs128, Richard Henderson, 2021/10/29
- [PULL v2 09/60] tcg/optimize: Change tcg_opt_gen_{mov, movi} interface, Richard Henderson, 2021/10/29
- [PULL v2 06/60] tcg/optimize: Rename "mask" to "z_mask", Richard Henderson, 2021/10/29
- [PULL v2 07/60] tcg/optimize: Split out OptContext, Richard Henderson, 2021/10/29
- [PULL v2 08/60] tcg/optimize: Remove do_default label, Richard Henderson, 2021/10/29
- [PULL v2 10/60] tcg/optimize: Move prev_mb into OptContext, Richard Henderson, 2021/10/29
- [PULL v2 13/60] tcg/optimize: Split out fold_call, Richard Henderson, 2021/10/29
- [PULL v2 12/60] tcg/optimize: Split out copy_propagate, Richard Henderson, 2021/10/29
- [PULL v2 15/60] tcg/optimize: Change fail return for do_constant_folding_cond*, Richard Henderson, 2021/10/29
- [PULL v2 17/60] tcg/optimize: Split out finish_folding,
Richard Henderson <=
- [PULL v2 16/60] tcg/optimize: Return true from tcg_opt_gen_{mov, movi}, Richard Henderson, 2021/10/29
- [PULL v2 18/60] tcg/optimize: Use a boolean to avoid a mass of continues, Richard Henderson, 2021/10/29
- [PULL v2 11/60] tcg/optimize: Split out init_arguments, Richard Henderson, 2021/10/29
- [PULL v2 14/60] tcg/optimize: Drop nb_oargs, nb_iargs locals, Richard Henderson, 2021/10/29
- [PULL v2 19/60] tcg/optimize: Split out fold_mb, fold_qemu_{ld,st}, Richard Henderson, 2021/10/29
- [PULL v2 22/60] tcg/optimize: Split out fold_brcond2, Richard Henderson, 2021/10/29
- [PULL v2 20/60] tcg/optimize: Split out fold_const{1,2}, Richard Henderson, 2021/10/29
- [PULL v2 25/60] tcg/optimize: Split out fold_mulu2_i32, Richard Henderson, 2021/10/29
- [PULL v2 21/60] tcg/optimize: Split out fold_setcond2, Richard Henderson, 2021/10/29
- [PULL v2 24/60] tcg/optimize: Split out fold_setcond, Richard Henderson, 2021/10/29