[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 56/81] tcg/optimize: Fold andc with immediate to and
From: |
Richard Henderson |
Subject: |
[PATCH v2 56/81] tcg/optimize: Fold andc with immediate to and |
Date: |
Tue, 7 Jan 2025 00:00:47 -0800 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 79af2c312a..1dd7b0e0bc 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1328,6 +1328,25 @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
t2 = arg_info(op->args[2]);
z_mask = t1->z_mask;
+ if (ti_is_const(t2)) {
+ /* Fold andc r,x,i to and r,x,~i. */
+ switch (ctx->type) {
+ case TCG_TYPE_I32:
+ case TCG_TYPE_I64:
+ op->opc = INDEX_op_and;
+ break;
+ case TCG_TYPE_V64:
+ case TCG_TYPE_V128:
+ case TCG_TYPE_V256:
+ op->opc = INDEX_op_and_vec;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ op->args[2] = arg_new_constant(ctx, ~ti_const_val(t2));
+ return fold_and(ctx, op);
+ }
+
/*
* Known-zeros does not imply known-ones. Therefore unless
* arg2 is constant, we can't infer anything from it.
--
2.43.0
- Re: [PATCH v2 27/81] tcg: Pass type and flags to tcg_target_op_def, (continued)
- [PATCH v2 30/81] tcg: Drop implementation checks from tcg-opc.h, Richard Henderson, 2025/01/07
- [PATCH v2 37/81] tcg/arm: Add full [US]XT[BH] into {s}extract, Richard Henderson, 2025/01/07
- [PATCH v2 39/81] tcg/mips: Fold the ext{8, 16, 32}[us] cases into {s}extract, Richard Henderson, 2025/01/07
- [PATCH v2 41/81] tcg/riscv64: Fold the ext{8, 16, 32}[us] cases into {s}extract, Richard Henderson, 2025/01/07
- [PATCH v2 56/81] tcg/optimize: Fold andc with immediate to and,
Richard Henderson <=
- [PATCH v2 55/81] tcg: Merge INDEX_op_and_{i32,i64}, Richard Henderson, 2025/01/07
- [PATCH v2 47/81] tcg: Remove TCG_TARGET_HAS_{s}extract_{i32,i64}, Richard Henderson, 2025/01/07
- [PATCH v2 44/81] tcg/sparc64: Use SRA, SRL for {s}extract_i64, Richard Henderson, 2025/01/07