tcg/optimize: Split out fold_brcond

Reviewed-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2021-08-24 09:30:59 -07:00
parent 764d2aba08
commit 079b08040e

View file

@ -714,6 +714,22 @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
return fold_const2(ctx, op);
}
static bool fold_brcond(OptContext *ctx, TCGOp *op)
{
TCGCond cond = op->args[2];
int i = do_constant_folding_cond(op->opc, op->args[0], op->args[1], cond);
if (i == 0) {
tcg_op_remove(ctx->tcg, op);
return true;
}
if (i > 0) {
op->opc = INDEX_op_br;
op->args[0] = op->args[3];
}
return false;
}
static bool fold_brcond2(OptContext *ctx, TCGOp *op)
{
TCGCond cond = op->args[4];
@ -1641,20 +1657,6 @@ void tcg_optimize(TCGContext *s)
}
break;
CASE_OP_32_64(brcond):
i = do_constant_folding_cond(opc, op->args[0],
op->args[1], op->args[2]);
if (i == 0) {
tcg_op_remove(s, op);
continue;
} else if (i > 0) {
memset(&ctx.temps_used, 0, sizeof(ctx.temps_used));
op->opc = opc = INDEX_op_br;
op->args[0] = op->args[3];
break;
}
break;
CASE_OP_32_64(movcond):
i = do_constant_folding_cond(opc, op->args[1],
op->args[2], op->args[5]);
@ -1737,6 +1739,9 @@ void tcg_optimize(TCGContext *s)
CASE_OP_32_64_VEC(andc):
done = fold_andc(&ctx, op);
break;
CASE_OP_32_64(brcond):
done = fold_brcond(&ctx, op);
break;
case INDEX_op_brcond2_i32:
done = fold_brcond2(&ctx, op);
break;