[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 26/48] tcg/optimize: Split out fold_count_zeros
From: |
Richard Henderson |
Subject: |
[PATCH 26/48] tcg/optimize: Split out fold_count_zeros |
Date: |
Sun, 29 Aug 2021 23:24:29 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 74c307951d..79e46fec23 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -875,6 +875,20 @@ static bool fold_call(OptContext *ctx, TCGOp *op)
return true;
}
+static bool fold_count_zeros(OptContext *ctx, TCGOp *op)
+{
+ if (arg_is_const(op->args[1])) {
+ uint64_t t = arg_info(op->args[1])->val;
+
+ if (t != 0) {
+ t = do_constant_folding(op->opc, t, 0);
+ return tcg_opt_gen_movi(ctx, op, op->args[0], t);
+ }
+ return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[2]);
+ }
+ return false;
+}
+
static bool fold_ctpop(OptContext *ctx, TCGOp *op)
{
return fold_const1(ctx, op);
@@ -1726,20 +1740,6 @@ void tcg_optimize(TCGContext *s)
}
break;
- CASE_OP_32_64(clz):
- CASE_OP_32_64(ctz):
- if (arg_is_const(op->args[1])) {
- TCGArg v = arg_info(op->args[1])->val;
- if (v != 0) {
- tmp = do_constant_folding(opc, v, 0);
- tcg_opt_gen_movi(&ctx, op, op->args[0], tmp);
- } else {
- tcg_opt_gen_mov(&ctx, op, op->args[0], op->args[2]);
- }
- continue;
- }
- break;
-
default:
break;
@@ -1764,6 +1764,10 @@ void tcg_optimize(TCGContext *s)
case INDEX_op_brcond2_i32:
done = fold_brcond2(&ctx, op);
break;
+ CASE_OP_32_64(clz):
+ CASE_OP_32_64(ctz):
+ done = fold_count_zeros(&ctx, op);
+ break;
CASE_OP_32_64(ctpop):
done = fold_ctpop(&ctx, op);
break;
--
2.25.1
- [PATCH 10/48] tcg/optimize: Change fail return for do_constant_folding_cond*, (continued)
- [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
- [PATCH 38/48] tcg/optimize: Split out fold_masks, Richard Henderson, 2021/08/30
- [PATCH 26/48] tcg/optimize: Split out fold_count_zeros,
Richard Henderson <=
- [PATCH 28/48] tcg/optimize: Split out fold_dup, fold_dup2, Richard Henderson, 2021/08/30
- [PATCH 11/48] tcg/optimize: Return true from tcg_opt_gen_{mov,movi}, Richard Henderson, 2021/08/30
- [PATCH 32/48] tcg/optimize: Split out fold_xi_to_i, Richard Henderson, 2021/08/30
- [PATCH 34/48] tcg/optimize: Split out fold_to_not, Richard Henderson, 2021/08/30
- [PATCH 31/48] tcg/optimize: Split out fold_xx_to_x, Richard Henderson, 2021/08/30
- [PATCH 33/48] tcg/optimize: Add type to OptContext, Richard Henderson, 2021/08/30
- [PATCH 35/48] tcg/optimize: Split out fold_sub_to_neg, Richard Henderson, 2021/08/30