From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com
Subject: [PATCH v2 20/27] tcg/optimize: Build and use o_bits in fold_sextract
Date: Tue, 3 Jun 2025 09:09:01 +0100 [thread overview]
Message-ID: <20250603080908.559594-21-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250603080908.559594-1-richard.henderson@linaro.org>
This was the last use of fold_affected_mask,
now fully replaced by fold_masks_zosa.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 30 ++++++------------------------
1 file changed, 6 insertions(+), 24 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index abcbee9111..673849f07a 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1121,22 +1121,6 @@ static bool fold_masks_s(OptContext *ctx, TCGOp *op, uint64_t s_mask)
return fold_masks_zosa(ctx, op, -1, 0, s_mask, -1);
}
-/*
- * An "affected" mask bit is 0 if and only if the result is identical
- * to the first input. Thus if the entire mask is 0, the operation
- * is equivalent to a copy.
- */
-static bool fold_affected_mask(OptContext *ctx, TCGOp *op, uint64_t a_mask)
-{
- if (ctx->type == TCG_TYPE_I32) {
- a_mask = (uint32_t)a_mask;
- }
- if (a_mask == 0) {
- return tcg_opt_gen_mov(ctx, op, op->args[0], op->args[1]);
- }
- return false;
-}
-
/*
* Convert @op to NOT, if NOT is supported by the host.
* Return true f the conversion is successful, which will still
@@ -2669,7 +2653,7 @@ static bool fold_setcond2(OptContext *ctx, TCGOp *op)
static bool fold_sextract(OptContext *ctx, TCGOp *op)
{
- uint64_t z_mask, s_mask, s_mask_old;
+ uint64_t z_mask, o_mask, s_mask, a_mask;
TempOptInfo *t1 = arg_info(op->args[1]);
int pos = op->args[2];
int len = op->args[3];
@@ -2679,16 +2663,14 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
sextract64(ti_const_val(t1), pos, len));
}
- s_mask_old = t1->s_mask;
- s_mask = s_mask_old >> pos;
+ s_mask = t1->s_mask >> pos;
s_mask |= -1ull << (len - 1);
-
- if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
- return true;
- }
+ a_mask = pos ? -1 : s_mask & ~t1->s_mask;
z_mask = sextract64(t1->z_mask, pos, len);
- return fold_masks_zs(ctx, op, z_mask, s_mask);
+ o_mask = sextract64(t1->o_mask, pos, len);
+
+ return fold_masks_zosa(ctx, op, z_mask, o_mask, s_mask, a_mask);
}
static bool fold_shift(OptContext *ctx, TCGOp *op)
--
2.43.0
next prev parent reply other threads:[~2025-06-03 8:12 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 8:08 [PATCH v2 00/27] tcg/optimize: Track and use known 1's Richard Henderson
2025-06-03 8:08 ` [PATCH v2 01/27] tcg/optimize: Introduce arg_const_val Richard Henderson
2025-06-25 14:45 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 02/27] tcg/optimize: Add one's mask to TempOptInfo Richard Henderson
2025-06-25 14:44 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 03/27] tcg/optimize: Introduce fold_masks_zosa Richard Henderson
2025-06-25 14:44 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 04/27] tcg/optimize: Build and use o_bits in fold_and Richard Henderson
2025-06-25 14:46 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 05/27] tcg/optimize: Build and use o_bits in fold_andc Richard Henderson
2025-06-25 14:46 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 06/27] tcg/optimize: Build and use z_bits and o_bits in fold_eqv Richard Henderson
2025-06-25 14:47 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 07/27] tcg/optimize: Build and use z_bits and o_bits in fold_nand Richard Henderson
2025-06-25 14:47 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 08/27] tcg/optimize: Build and use z_bits and o_bits in fold_nor Richard Henderson
2025-06-25 14:48 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 09/27] tcg/optimize: Build and use z_bits and o_bits in fold_not Richard Henderson
2025-06-25 14:48 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 10/27] tcg/optimize: Build and use one and affected bits in fold_or Richard Henderson
2025-06-25 14:48 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 11/27] tcg/optimize: Build and use zero, one and affected bits in fold_orc Richard Henderson
2025-06-25 14:49 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 12/27] tcg/optimize: Build and use o_bits in fold_xor Richard Henderson
2025-06-25 14:49 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 13/27] tcg/optimize: Build and use o_bits in fold_bswap Richard Henderson
2025-06-25 14:52 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 14/27] tcg/optimize: Build and use o_bits in fold_deposit Richard Henderson
2025-06-25 14:53 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 15/27] tcg/optimize: Build and use o_bits in fold_extract Richard Henderson
2025-06-25 14:54 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 16/27] tcg/optimize: Build and use z_bits and o_bits in fold_extract2 Richard Henderson
2025-06-25 14:54 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 17/27] tcg/optimize: Build and use o_bits in fold_exts Richard Henderson
2025-06-25 14:54 ` Pierrick Bouvier
2025-06-03 8:08 ` [PATCH v2 18/27] tcg/optimize: Build and use o_bits in fold_extu Richard Henderson
2025-06-25 14:55 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 19/27] tcg/optimize: Build and use o_bits in fold_movcond Richard Henderson
2025-06-25 14:55 ` Pierrick Bouvier
2025-06-03 8:09 ` Richard Henderson [this message]
2025-06-25 14:55 ` [PATCH v2 20/27] tcg/optimize: Build and use o_bits in fold_sextract Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 21/27] tcg/optimize: Build and use o_bits in fold_shift Richard Henderson
2025-06-25 14:56 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 22/27] tcg/optimize: Use fold_and in do_constant_folding_cond[12] Richard Henderson
2025-06-25 14:56 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 23/27] tcg/optimize: Fold and to extract during optimize Richard Henderson
2025-06-25 14:57 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 24/27] tcg/optimize: Simplify fold_and constant checks Richard Henderson
2025-06-25 14:57 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 25/27] tcg/optimize: Simplify fold_andc " Richard Henderson
2025-06-25 14:57 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 26/27] tcg/optimize: Simplify fold_orc " Richard Henderson
2025-06-25 14:57 ` Pierrick Bouvier
2025-06-03 8:09 ` [PATCH v2 27/27] tcg/optimize: Simplify fold_eqv " Richard Henderson
2025-06-25 14:57 ` Pierrick Bouvier
2025-06-23 18:45 ` [PATCH v2 00/27] tcg/optimize: Track and use known 1's Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250603080908.559594-21-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).