[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 23/48] tcg/optimize: Split out fold_extract2
From: |
Richard Henderson |
Subject: |
[PATCH v3 23/48] tcg/optimize: Split out fold_extract2 |
Date: |
Thu, 21 Oct 2021 14:05:14 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index ed5a304089..885380bb22 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -883,6 +883,25 @@ static bool fold_eqv(OptContext *ctx, TCGOp *op)
return fold_const2(ctx, op);
}
+static bool fold_extract2(OptContext *ctx, TCGOp *op)
+{
+ if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {
+ uint64_t v1 = arg_info(op->args[1])->val;
+ uint64_t v2 = arg_info(op->args[2])->val;
+ int shr = op->args[3];
+
+ if (op->opc == INDEX_op_extract2_i64) {
+ v1 >>= shr;
+ v2 <<= 64 - shr;
+ } else {
+ v1 = (uint32_t)v1 >> shr;
+ v2 = (int32_t)v2 << (32 - shr);
+ }
+ return tcg_opt_gen_movi(ctx, op, op->args[0], v1 | v2);
+ }
+ return false;
+}
+
static bool fold_exts(OptContext *ctx, TCGOp *op)
{
return fold_const1(ctx, op);
@@ -1711,23 +1730,6 @@ void tcg_optimize(TCGContext *s)
}
break;
- CASE_OP_32_64(extract2):
- if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {
- uint64_t v1 = arg_info(op->args[1])->val;
- uint64_t v2 = arg_info(op->args[2])->val;
- int shr = op->args[3];
-
- if (opc == INDEX_op_extract2_i64) {
- tmp = (v1 >> shr) | (v2 << (64 - shr));
- } else {
- tmp = (int32_t)(((uint32_t)v1 >> shr) |
- ((uint32_t)v2 << (32 - shr)));
- }
- tcg_opt_gen_movi(&ctx, op, op->args[0], tmp);
- continue;
- }
- break;
-
default:
break;
@@ -1762,6 +1764,9 @@ void tcg_optimize(TCGContext *s)
CASE_OP_32_64(eqv):
done = fold_eqv(&ctx, op);
break;
+ CASE_OP_32_64(extract2):
+ done = fold_extract2(&ctx, op);
+ break;
CASE_OP_32_64(ext8s):
CASE_OP_32_64(ext16s):
case INDEX_op_ext32s_i64:
--
2.25.1
- Re: [PATCH v3 18/48] tcg/optimize: Split out fold_brcond, (continued)
- [PATCH v3 04/48] tcg/optimize: Change tcg_opt_gen_{mov, movi} interface, Richard Henderson, 2021/10/21
- [PATCH v3 07/48] tcg/optimize: Split out copy_propagate, Richard Henderson, 2021/10/21
- [PATCH v3 15/48] tcg/optimize: Split out fold_const{1,2}, Richard Henderson, 2021/10/21
- [PATCH v3 13/48] tcg/optimize: Use a boolean to avoid a mass of continues, Richard Henderson, 2021/10/21
- [PATCH v3 22/48] tcg/optimize: Split out fold_movcond, Richard Henderson, 2021/10/21
- [PATCH v3 19/48] tcg/optimize: Split out fold_setcond, Richard Henderson, 2021/10/21
- [PATCH v3 23/48] tcg/optimize: Split out fold_extract2,
Richard Henderson <=
- [PATCH v3 21/48] tcg/optimize: Split out fold_addsub2_i32, Richard Henderson, 2021/10/21
- [PATCH v3 17/48] tcg/optimize: Split out fold_brcond2, Richard Henderson, 2021/10/21
- [PATCH v3 31/48] tcg/optimize: Split out fold_xx_to_x, Richard Henderson, 2021/10/21
- [PATCH v3 32/48] tcg/optimize: Split out fold_xi_to_i, Richard Henderson, 2021/10/21