aboutsummaryrefslogtreecommitdiff
path: root/tcg/optimize.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2021-08-24 09:30:59 -0700
committerRichard Henderson <richard.henderson@linaro.org>2021-10-27 17:11:22 -0700
commit079b08040e0c4eed96b3c19fe37cf17a46294d2b (patch)
treef5c1475ec16f35c7a8fb8d4ae7a64f21e93f5675 /tcg/optimize.c
parent764d2aba08c35f2462371b01c27fb032447afcd8 (diff)
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>
Diffstat (limited to 'tcg/optimize.c')
-rw-r--r--tcg/optimize.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/tcg/optimize.c b/tcg/optimize.c
index c9db14f1d0..24ba6d2830 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -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;