[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 40/51] tcg/optimize: Canonicalize s_mask in fold_exts, fold_se
From: |
Richard Henderson |
Subject: |
[PATCH v2 40/51] tcg/optimize: Canonicalize s_mask in fold_exts, fold_sextract |
Date: |
Thu, 19 Dec 2024 20:10:52 -0800 |
Simply or'ing the an input s_mask with the mask implied by
the sign extension operation may leave disconnected bits
to the right. Use smask_from_smask to canonicalize.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index d0a9ea1ee4..8735dc0c9c 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1827,6 +1827,7 @@ static bool fold_exts(OptContext *ctx, TCGOp *op)
g_assert_not_reached();
}
s_mask |= sign << 1;
+ s_mask = smask_from_smask(s_mask);
if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
return true;
@@ -2534,8 +2535,13 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
}
s_mask_old = t1->s_mask;
+ /*
+ * Use the sign mask from the input, force the repetitons from
+ * the sign extension operation, and canonicalize the result.
+ */
s_mask = sextract64(s_mask_old, pos, len);
s_mask |= MAKE_64BIT_MASK(len, 64 - len);
+ s_mask = smask_from_smask(s_mask);
if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
return true;
--
2.43.0
- [PATCH v2 47/51] tcg/optimize: Use finish_folding in fold_bitsel_vec, (continued)
- [PATCH v2 47/51] tcg/optimize: Use finish_folding in fold_bitsel_vec, Richard Henderson, 2024/12/19
- [PATCH v2 48/51] tcg/optimize: Use finish_folding as default in tcg_optimize, Richard Henderson, 2024/12/19
- [PATCH v2 42/51] tcg/optimize: Simplify sign bit test in fold_shift, Richard Henderson, 2024/12/19
- [PATCH v2 44/51] tcg/optimize: Use fold_masks_zs in fold_tcg_ld, Richard Henderson, 2024/12/19
- [PATCH v2 49/51] tcg/optimize: Remove z_mask, s_mask from OptContext, Richard Henderson, 2024/12/19
- [PATCH v2 50/51] tcg/optimize: Move fold_bitsel_vec into alphabetic sort, Richard Henderson, 2024/12/19
- [PATCH v2 43/51] tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec, Richard Henderson, 2024/12/19
- [PATCH v2 46/51] tcg/optimize: Use fold_masks_zs in fold_xor, Richard Henderson, 2024/12/19
- [PATCH v2 51/51] tcg/optimize: Move fold_cmp_vec, fold_cmpsel_vec into alphabetic sort, Richard Henderson, 2024/12/19
- [PATCH v2 40/51] tcg/optimize: Canonicalize s_mask in fold_exts, fold_sextract,
Richard Henderson <=
- [PATCH v2 41/51] tcg/optimize: Use fold_masks_zs, fold_masks_s in fold_shift, Richard Henderson, 2024/12/19