[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 22/48] tcg/optimize: Split out fold_movcond
From: |
Richard Henderson |
Subject: |
[PATCH 22/48] tcg/optimize: Split out fold_movcond |
Date: |
Sun, 29 Aug 2021 23:24:25 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 56 ++++++++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 25 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index b72fe6e847..d9592a039c 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -919,6 +919,34 @@ static bool fold_mb(OptContext *ctx, TCGOp *op)
return true;
}
+static bool fold_movcond(OptContext *ctx, TCGOp *op)
+{
+ TCGOpcode opc = op->opc;
+ TCGCond cond = op->args[5];
+ int i = do_constant_folding_cond(opc, op->args[1], op->args[2], cond);
+
+ if (i >= 0) {
+ return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[4 - i]);
+ }
+
+ if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) {
+ uint64_t tv = arg_info(op->args[3])->val;
+ uint64_t fv = arg_info(op->args[4])->val;
+
+ opc = (opc == INDEX_op_movcond_i32
+ ? INDEX_op_setcond_i32 : INDEX_op_setcond_i64);
+
+ if (tv == 1 && fv == 0) {
+ op->opc = opc;
+ op->args[3] = cond;
+ } else if (fv == 1 && tv == 0) {
+ op->opc = opc;
+ op->args[3] = tcg_invert_cond(cond);
+ }
+ }
+ return false;
+}
+
static bool fold_multiply(OptContext *ctx, TCGOp *op)
{
return fold_const2(ctx, op);
@@ -1702,31 +1730,6 @@ void tcg_optimize(TCGContext *s)
}
break;
- CASE_OP_32_64(movcond):
- i = do_constant_folding_cond(opc, op->args[1],
- op->args[2], op->args[5]);
- if (i >= 0) {
- tcg_opt_gen_mov(&ctx, op, op->args[0], op->args[4 - i]);
- continue;
- }
- if (arg_is_const(op->args[3]) && arg_is_const(op->args[4])) {
- uint64_t tv = arg_info(op->args[3])->val;
- uint64_t fv = arg_info(op->args[4])->val;
- TCGCond cond = op->args[5];
-
- if (fv == 1 && tv == 0) {
- cond = tcg_invert_cond(cond);
- } else if (!(tv == 1 && fv == 0)) {
- break;
- }
- op->args[3] = cond;
- op->opc = opc = (opc == INDEX_op_movcond_i32
- ? INDEX_op_setcond_i32
- : INDEX_op_setcond_i64);
- }
- break;
-
-
default:
break;
@@ -1778,6 +1781,9 @@ void tcg_optimize(TCGContext *s)
case INDEX_op_mb:
done = fold_mb(&ctx, op);
break;
+ CASE_OP_32_64(movcond):
+ done = fold_movcond(&ctx, op);
+ break;
CASE_OP_32_64(mul):
CASE_OP_32_64(mulsh):
CASE_OP_32_64(muluh):
--
2.25.1
- [PATCH 12/48] tcg/optimize: Split out finish_folding, (continued)
- [PATCH 12/48] tcg/optimize: Split out finish_folding, Richard Henderson, 2021/08/30
- [PATCH 14/48] tcg/optimize: Split out fold_mb, fold_qemu_{ld,st}, Richard Henderson, 2021/08/30
- [PATCH 13/48] tcg/optimize: Use a boolean to avoid a mass of continues, Richard Henderson, 2021/08/30
- [PATCH 16/48] tcg/optimize: Split out fold_setcond2, Richard Henderson, 2021/08/30
- [PATCH 19/48] tcg/optimize: Split out fold_setcond, Richard Henderson, 2021/08/30
- [PATCH 18/48] tcg/optimize: Split out fold_brcond, Richard Henderson, 2021/08/30
- [PATCH 17/48] tcg/optimize: Split out fold_brcond2, Richard Henderson, 2021/08/30
- [PATCH 20/48] tcg/optimize: Split out fold_mulu2_i32, Richard Henderson, 2021/08/30
- [PATCH 21/48] tcg/optimize: Split out fold_addsub2_i32, Richard Henderson, 2021/08/30
- [PATCH 22/48] tcg/optimize: Split out fold_movcond,
Richard Henderson <=
- [PATCH 23/48] tcg/optimize: Split out fold_extract2, Richard Henderson, 2021/08/30
- [PATCH 15/48] tcg/optimize: Split out fold_const{1,2}, Richard Henderson, 2021/08/30
- [PATCH 10/48] tcg/optimize: Change fail return for do_constant_folding_cond*, Richard Henderson, 2021/08/30
- [PATCH 25/48] tcg/optimize: Split out fold_deposit, Richard Henderson, 2021/08/30
- [PATCH 24/48] tcg/optimize: Split out fold_extract, fold_sextract, Richard Henderson, 2021/08/30
- [PATCH 27/48] tcg/optimize: Split out fold_bswap, Richard Henderson, 2021/08/30
- [PATCH 29/48] tcg/optimize: Split out fold_mov, Richard Henderson, 2021/08/30
- [PATCH 30/48] tcg/optimize: Split out fold_xx_to_i, Richard Henderson, 2021/08/30