[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/20] tcg/optimize: Build and use o_bits in fold_andc
From: |
Richard Henderson |
Subject: |
[PATCH 04/20] tcg/optimize: Build and use o_bits in fold_andc |
Date: |
Mon, 5 May 2025 13:27:35 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index c9f0f46b83..faee3e8580 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1451,7 +1451,7 @@ static bool fold_and(OptContext *ctx, TCGOp *op)
static bool fold_andc(OptContext *ctx, TCGOp *op)
{
- uint64_t z_mask, s_mask;
+ uint64_t z_mask, o_mask, s_mask;
TempOptInfo *t1, *t2;
if (fold_const2(ctx, op) ||
@@ -1463,7 +1463,6 @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
t1 = arg_info(op->args[1]);
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. */
@@ -1484,20 +1483,16 @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
return fold_and(ctx, op);
}
- /*
- * Known-zeros does not imply known-ones. Therefore unless
- * arg2 is constant, we can't infer anything from it.
- */
- if (ti_is_const(t2)) {
- uint64_t v2 = ti_const_val(t2);
- if (fold_affected_mask(ctx, op, z_mask & v2)) {
- return true;
- }
- z_mask &= ~v2;
+ /* Affected bits are those not known zero, masked by those known zero. */
+ if (fold_affected_mask(ctx, op, t1->z_mask & t2->z_mask)) {
+ return true;
}
+ z_mask = t1->z_mask & ~t2->o_mask;
+ o_mask = t1->o_mask & ~t2->z_mask;
s_mask = t1->s_mask & t2->s_mask;
- return fold_masks_zs(ctx, op, z_mask, s_mask);
+
+ return fold_masks_zos(ctx, op, z_mask, o_mask, s_mask);
}
static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)
--
2.43.0
- [PATCH 00/20] tcg/optimize: Track and use known 1's, Richard Henderson, 2025/05/05
- [PATCH 08/20] tcg/optimize: Build and use z_bits and o_bits in fold_not, Richard Henderson, 2025/05/05
- [PATCH 07/20] tcg/optimize: Build and use z_bits and o_bits in fold_nor, Richard Henderson, 2025/05/05
- [PATCH 06/20] tcg/optimize: Build and use z_bits and o_bits in fold_nand, Richard Henderson, 2025/05/05
- [PATCH 02/20] tcg/optimize: Add one's mask to TempOptInfo, Richard Henderson, 2025/05/05
- [PATCH 04/20] tcg/optimize: Build and use o_bits in fold_andc,
Richard Henderson <=
- [PATCH 03/20] tcg/optimize: Build and use o_bits in fold_and, Richard Henderson, 2025/05/05
- [PATCH 10/20] tcg/optimize: Build and use zero, one and affected bits in fold_orc, Richard Henderson, 2025/05/05
- [PATCH 15/20] tcg/optimize: Build and use z_bits and o_bits in fold_extract2, Richard Henderson, 2025/05/05
- [PATCH 11/20] tcg/optimize: Build and use o_bits in fold_xor, Richard Henderson, 2025/05/05
- [PATCH 05/20] tcg/optimize: Build and use z_bits and o_bits in fold_eqv, Richard Henderson, 2025/05/05
- [PATCH 01/20] tcg/optimize: Introduce arg_const_val, Richard Henderson, 2025/05/05
- [PATCH 09/20] tcg/optimize: Build and use one and affected bits in fold_or, Richard Henderson, 2025/05/05
- [PATCH 16/20] tcg/optimize: Build and use o_bits in fold_exts, Richard Henderson, 2025/05/05