tcg/optimize: Drop nb_oargs, nb_iargs locals

Rather than try to keep these up-to-date across folding,
re-read nb_oargs at the end, after re-reading the opcode.

A couple of asserts need dropping, but that will take care
of itself as we split the function further.

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>
master
Richard Henderson 2021-08-24 08:20:27 -07:00
parent 5cf32be7d8
commit ec5d4cbeef
1 changed files with 4 additions and 10 deletions

View File

@ -675,7 +675,6 @@ void tcg_optimize(TCGContext *s)
QTAILQ_FOREACH_SAFE(op, &s->ops, link, op_next) { QTAILQ_FOREACH_SAFE(op, &s->ops, link, op_next) {
uint64_t z_mask, partmask, affected, tmp; uint64_t z_mask, partmask, affected, tmp;
int nb_oargs, nb_iargs;
TCGOpcode opc = op->opc; TCGOpcode opc = op->opc;
const TCGOpDef *def; const TCGOpDef *def;
@ -686,10 +685,8 @@ void tcg_optimize(TCGContext *s)
} }
def = &tcg_op_defs[opc]; def = &tcg_op_defs[opc];
nb_oargs = def->nb_oargs; init_arguments(&ctx, op, def->nb_oargs + def->nb_iargs);
nb_iargs = def->nb_iargs; copy_propagate(&ctx, op, def->nb_oargs, def->nb_iargs);
init_arguments(&ctx, op, nb_oargs + nb_iargs);
copy_propagate(&ctx, op, nb_oargs, nb_iargs);
/* For commutative operations make constant second argument */ /* For commutative operations make constant second argument */
switch (opc) { switch (opc) {
@ -1063,7 +1060,7 @@ void tcg_optimize(TCGContext *s)
CASE_OP_32_64(qemu_ld): CASE_OP_32_64(qemu_ld):
{ {
MemOpIdx oi = op->args[nb_oargs + nb_iargs]; MemOpIdx oi = op->args[def->nb_oargs + def->nb_iargs];
MemOp mop = get_memop(oi); MemOp mop = get_memop(oi);
if (!(mop & MO_SIGN)) { if (!(mop & MO_SIGN)) {
z_mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1; z_mask = (2ULL << ((8 << (mop & MO_SIZE)) - 1)) - 1;
@ -1122,12 +1119,10 @@ void tcg_optimize(TCGContext *s)
} }
if (partmask == 0) { if (partmask == 0) {
tcg_debug_assert(nb_oargs == 1);
tcg_opt_gen_movi(&ctx, op, op->args[0], 0); tcg_opt_gen_movi(&ctx, op, op->args[0], 0);
continue; continue;
} }
if (affected == 0) { if (affected == 0) {
tcg_debug_assert(nb_oargs == 1);
tcg_opt_gen_mov(&ctx, op, op->args[0], op->args[1]); tcg_opt_gen_mov(&ctx, op, op->args[0], op->args[1]);
continue; continue;
} }
@ -1202,7 +1197,6 @@ void tcg_optimize(TCGContext *s)
} else if (args_are_copies(op->args[1], op->args[2])) { } else if (args_are_copies(op->args[1], op->args[2])) {
op->opc = INDEX_op_dup_vec; op->opc = INDEX_op_dup_vec;
TCGOP_VECE(op) = MO_32; TCGOP_VECE(op) = MO_32;
nb_iargs = 1;
} }
break; break;
@ -1371,7 +1365,6 @@ void tcg_optimize(TCGContext *s)
op->opc = opc = (opc == INDEX_op_movcond_i32 op->opc = opc = (opc == INDEX_op_movcond_i32
? INDEX_op_setcond_i32 ? INDEX_op_setcond_i32
: INDEX_op_setcond_i64); : INDEX_op_setcond_i64);
nb_iargs = 2;
} }
break; break;
@ -1579,6 +1572,7 @@ void tcg_optimize(TCGContext *s)
if (def->flags & TCG_OPF_BB_END) { if (def->flags & TCG_OPF_BB_END) {
memset(&ctx.temps_used, 0, sizeof(ctx.temps_used)); memset(&ctx.temps_used, 0, sizeof(ctx.temps_used));
} else { } else {
int nb_oargs = def->nb_oargs;
for (i = 0; i < nb_oargs; i++) { for (i = 0; i < nb_oargs; i++) {
reset_temp(op->args[i]); reset_temp(op->args[i]);
/* Save the corresponding known-zero bits mask for the /* Save the corresponding known-zero bits mask for the