tcg: don't keep dead outputs in registers
If an op with dead outputs is not removed, because it has side effects or has multiple output and only one dead, mark the registers as dead instead of saving them. This avoid a few register spills on TCG targets with low register count, especially with div2 and mul2 ops, or when a qemu_ld* result is not used (prefetch emulation for example). Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
parent
6b64b624cd
commit
8c11ad25f4
|
@ -1782,6 +1782,9 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
if (!ts->fixed_reg) {
|
if (!ts->fixed_reg) {
|
||||||
if (ts->val_type == TEMP_VAL_REG)
|
if (ts->val_type == TEMP_VAL_REG)
|
||||||
s->reg_to_temp[ts->reg] = -1;
|
s->reg_to_temp[ts->reg] = -1;
|
||||||
|
if (IS_DEAD_ARG(i)) {
|
||||||
|
ts->val_type = TEMP_VAL_DEAD;
|
||||||
|
} else {
|
||||||
ts->val_type = TEMP_VAL_REG;
|
ts->val_type = TEMP_VAL_REG;
|
||||||
ts->reg = reg;
|
ts->reg = reg;
|
||||||
/* temp value is modified, so the value kept in memory is
|
/* temp value is modified, so the value kept in memory is
|
||||||
|
@ -1789,6 +1792,7 @@ static void tcg_reg_alloc_op(TCGContext *s,
|
||||||
ts->mem_coherent = 0;
|
ts->mem_coherent = 0;
|
||||||
s->reg_to_temp[reg] = arg;
|
s->reg_to_temp[reg] = arg;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
oarg_end:
|
oarg_end:
|
||||||
new_args[i] = reg;
|
new_args[i] = reg;
|
||||||
}
|
}
|
||||||
|
@ -1981,12 +1985,16 @@ static int tcg_reg_alloc_call(TCGContext *s, const TCGOpDef *def,
|
||||||
} else {
|
} else {
|
||||||
if (ts->val_type == TEMP_VAL_REG)
|
if (ts->val_type == TEMP_VAL_REG)
|
||||||
s->reg_to_temp[ts->reg] = -1;
|
s->reg_to_temp[ts->reg] = -1;
|
||||||
|
if (IS_DEAD_ARG(i)) {
|
||||||
|
ts->val_type = TEMP_VAL_DEAD;
|
||||||
|
} else {
|
||||||
ts->val_type = TEMP_VAL_REG;
|
ts->val_type = TEMP_VAL_REG;
|
||||||
ts->reg = reg;
|
ts->reg = reg;
|
||||||
ts->mem_coherent = 0;
|
ts->mem_coherent = 0;
|
||||||
s->reg_to_temp[reg] = arg;
|
s->reg_to_temp[reg] = arg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nb_iargs + nb_oargs + def->nb_cargs + 1;
|
return nb_iargs + nb_oargs + def->nb_cargs + 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue