aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-12-09 16:48:36 -0600
committerRichard Henderson <richard.henderson@linaro.org>2025-06-30 07:42:37 -0600
commit1e2edf85cc4755c844f9c98cbe52ac63d7d1fb18 (patch)
tree21c8751a781ef7c6cbd38caee43a6f5c18235628
parent9e397cc0df9c642381e60f97ce37eafe5a2582b3 (diff)
downloadqemu-1e2edf85cc4755c844f9c98cbe52ac63d7d1fb18.zip
qemu-1e2edf85cc4755c844f9c98cbe52ac63d7d1fb18.tar.gz
qemu-1e2edf85cc4755c844f9c98cbe52ac63d7d1fb18.tar.bz2
tcg/optimize: Build and use o_bits in fold_and
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
-rw-r--r--tcg/optimize.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/tcg/optimize.c b/tcg/optimize.c
index 49ef039..d9ccbb3 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1422,7 +1422,7 @@ static bool fold_addco(OptContext *ctx, TCGOp *op)
static bool fold_and(OptContext *ctx, TCGOp *op)
{
- uint64_t z1, z2, z_mask, s_mask;
+ uint64_t z_mask, o_mask, s_mask, a_mask;
TempOptInfo *t1, *t2;
if (fold_const2_commutative(ctx, op) ||
@@ -1434,18 +1434,9 @@ static bool fold_and(OptContext *ctx, TCGOp *op)
t1 = arg_info(op->args[1]);
t2 = arg_info(op->args[2]);
- z1 = t1->z_mask;
- z2 = t2->z_mask;
- /*
- * Known-zeros does not imply known-ones. Therefore unless
- * arg2 is constant, we can't infer affected bits from it.
- */
- if (ti_is_const(t2) && fold_affected_mask(ctx, op, z1 & ~z2)) {
- return true;
- }
-
- z_mask = z1 & z2;
+ z_mask = t1->z_mask & t2->z_mask;
+ o_mask = t1->o_mask & t2->o_mask;
/*
* Sign repetitions are perforce all identical, whether they are 1 or 0.
@@ -1453,7 +1444,10 @@ static bool fold_and(OptContext *ctx, TCGOp *op)
*/
s_mask = t1->s_mask & t2->s_mask;
- return fold_masks_zs(ctx, op, z_mask, s_mask);
+ /* Affected bits are those not known zero, masked by those known one. */
+ a_mask = t1->z_mask & ~t2->o_mask;
+
+ return fold_masks_zosa(ctx, op, z_mask, o_mask, s_mask, a_mask);
}
static bool fold_andc(OptContext *ctx, TCGOp *op)