Message ID | 20241210152401.1823648-3-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | tcg: Remove in-flight mask data from OptContext | expand |
On 12/10/24 07:23, Richard Henderson wrote: > Use of fold_masks should be restricted to those opcodes that > can reliably make use of it -- those with a single output, > and from higher-level folders that set up the masks. > Prepare for conversion of each folder in turn. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > tcg/optimize.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/tcg/optimize.c b/tcg/optimize.c > index 20c918e83b..1a9e3258e3 100644 > --- a/tcg/optimize.c > +++ b/tcg/optimize.c > @@ -1050,6 +1050,11 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) > uint64_t a_mask = ctx->a_mask; > uint64_t z_mask = ctx->z_mask; > uint64_t s_mask = ctx->s_mask; > + const TCGOpDef *def = &tcg_op_defs[op->opc]; > + TCGTemp *ts; > + > + /* Only single-output opcodes are supported here. */ > + tcg_debug_assert(def->nb_oargs == 1); > > /* > * 32-bit ops generate 32-bit results, which for the purpose of > @@ -1062,8 +1067,6 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) > a_mask = (int32_t)a_mask; > z_mask = (int32_t)z_mask; > s_mask |= MAKE_64BIT_MASK(32, 32); > - ctx->z_mask = z_mask; > - ctx->s_mask = s_mask; > } > > if (z_mask == 0) { > @@ -1072,7 +1075,12 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) > if (a_mask == 0) { > return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); > } > - return false; > + > + ts = arg_temp(op->args[0]); > + reset_ts(ctx, ts); > + ts_info(ts)->z_mask = z_mask; > + ts_info(ts)->s_mask = s_mask; > + return true; > } > > /* Maybe it would be worth to add a comment stating that a_mask was not modified, but only clipped to a 32 bit value. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff --git a/tcg/optimize.c b/tcg/optimize.c index 20c918e83b..1a9e3258e3 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -1050,6 +1050,11 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) uint64_t a_mask = ctx->a_mask; uint64_t z_mask = ctx->z_mask; uint64_t s_mask = ctx->s_mask; + const TCGOpDef *def = &tcg_op_defs[op->opc]; + TCGTemp *ts; + + /* Only single-output opcodes are supported here. */ + tcg_debug_assert(def->nb_oargs == 1); /* * 32-bit ops generate 32-bit results, which for the purpose of @@ -1062,8 +1067,6 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) a_mask = (int32_t)a_mask; z_mask = (int32_t)z_mask; s_mask |= MAKE_64BIT_MASK(32, 32); - ctx->z_mask = z_mask; - ctx->s_mask = s_mask; } if (z_mask == 0) { @@ -1072,7 +1075,12 @@ static bool fold_masks(OptContext *ctx, TCGOp *op) if (a_mask == 0) { return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]); } - return false; + + ts = arg_temp(op->args[0]); + reset_ts(ctx, ts); + ts_info(ts)->z_mask = z_mask; + ts_info(ts)->s_mask = s_mask; + return true; } /*
Use of fold_masks should be restricted to those opcodes that can reliably make use of it -- those with a single output, and from higher-level folders that set up the masks. Prepare for conversion of each folder in turn. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- tcg/optimize.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)