[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/51] tcg/optimize: Use fold_and and fold_masks_z in fold_dep
From: |
Richard Henderson |
Subject: |
[PATCH v2 12/51] tcg/optimize: Use fold_and and fold_masks_z in fold_deposit |
Date: |
Thu, 19 Dec 2024 20:10:24 -0800 |
Avoid the use of the OptContext slots. Find TempOptInfo once.
When we fold to and, use fold_and.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index af7111c98c..de32cc0323 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1642,14 +1642,16 @@ static bool fold_ctpop(OptContext *ctx, TCGOp *op)
static bool fold_deposit(OptContext *ctx, TCGOp *op)
{
+ TempOptInfo *t1 = arg_info(op->args[1]);
+ TempOptInfo *t2 = arg_info(op->args[2]);
+ int ofs = op->args[3];
+ int len = op->args[4];
TCGOpcode and_opc;
+ uint64_t z_mask;
- if (arg_is_const(op->args[1]) && arg_is_const(op->args[2])) {
- uint64_t t1 = arg_info(op->args[1])->val;
- uint64_t t2 = arg_info(op->args[2])->val;
-
- t1 = deposit64(t1, op->args[3], op->args[4], t2);
- return tcg_opt_gen_movi(ctx, op, op->args[0], t1);
+ if (t1->is_const && t2->is_const) {
+ return tcg_opt_gen_movi(ctx, op, op->args[0],
+ deposit64(t1->val, ofs, len, t2->val));
}
switch (ctx->type) {
@@ -1664,30 +1666,26 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
}
/* Inserting a value into zero at offset 0. */
- if (arg_is_const_val(op->args[1], 0) && op->args[3] == 0) {
- uint64_t mask = MAKE_64BIT_MASK(0, op->args[4]);
+ if (t1->is_const && t1->val == 0 && ofs == 0) {
+ uint64_t mask = MAKE_64BIT_MASK(0, len);
op->opc = and_opc;
op->args[1] = op->args[2];
op->args[2] = arg_new_constant(ctx, mask);
- ctx->z_mask = mask & arg_info(op->args[1])->z_mask;
- return false;
+ return fold_and(ctx, op);
}
/* Inserting zero into a value. */
- if (arg_is_const_val(op->args[2], 0)) {
- uint64_t mask = deposit64(-1, op->args[3], op->args[4], 0);
+ if (t2->is_const && t2->val == 0) {
+ uint64_t mask = deposit64(-1, ofs, len, 0);
op->opc = and_opc;
op->args[2] = arg_new_constant(ctx, mask);
- ctx->z_mask = mask & arg_info(op->args[1])->z_mask;
- return false;
+ return fold_and(ctx, op);
}
- ctx->z_mask = deposit64(arg_info(op->args[1])->z_mask,
- op->args[3], op->args[4],
- arg_info(op->args[2])->z_mask);
- return false;
+ z_mask = deposit64(t1->z_mask, ofs, len, t2->z_mask);
+ return fold_masks_z(ctx, op, z_mask);
}
static bool fold_divide(OptContext *ctx, TCGOp *op)
--
2.43.0
- [PATCH v2 03/51] tcg/optimize: Copy mask writeback to fold_masks, (continued)
- [PATCH v2 03/51] tcg/optimize: Copy mask writeback to fold_masks, Richard Henderson, 2024/12/19
- [PATCH v2 02/51] tcg/optimize: Split out fold_affected_mask, Richard Henderson, 2024/12/19
- [PATCH v2 01/51] tcg/optimize: Split out finish_bb, finish_ebb, Richard Henderson, 2024/12/19
- [PATCH v2 05/51] tcg/optimize: Augment s_mask from z_mask in fold_masks_zs, Richard Henderson, 2024/12/19
- [PATCH v2 06/51] tcg/optimize: Use finish_folding in fold_add, fold_add_vec, fold_addsub2, Richard Henderson, 2024/12/19
- [PATCH v2 07/51] tcg/optimize: Use fold_masks_zs in fold_and, Richard Henderson, 2024/12/19
- [PATCH v2 11/51] tcg/optimize: Use fold_masks_z in fold_ctpop, Richard Henderson, 2024/12/19
- [PATCH v2 08/51] tcg/optimize: Use fold_masks_zs in fold_andc, Richard Henderson, 2024/12/19
- [PATCH v2 12/51] tcg/optimize: Use fold_and and fold_masks_z in fold_deposit,
Richard Henderson <=
- [PATCH v2 09/51] tcg/optimize: Use fold_masks_zs in fold_bswap, Richard Henderson, 2024/12/19
- [PATCH v2 14/51] tcg/optimize: Use finish_folding in fold_divide, Richard Henderson, 2024/12/19
- [PATCH v2 17/51] tcg/optimize: Use fold_masks_z in fold_extract, Richard Henderson, 2024/12/19
- [PATCH v2 20/51] tcg/optimize: Use fold_masks_z in fold_extu, Richard Henderson, 2024/12/19
- [PATCH v2 13/51] tcg/optimize: Compute sign mask in fold_deposit, Richard Henderson, 2024/12/19
- [PATCH v2 16/51] tcg/optimize: Use fold_masks_s in fold_eqv, Richard Henderson, 2024/12/19
- [PATCH v2 15/51] tcg/optimize: Use finish_folding in fold_dup, fold_dup2, Richard Henderson, 2024/12/19
- [PATCH v2 22/51] tcg/optimize: Use finish_folding in fold_mul*, Richard Henderson, 2024/12/19
- [PATCH v2 23/51] tcg/optimize: Use fold_masks_s in fold_nand, Richard Henderson, 2024/12/19