qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 40/51] tcg/optimize: Canonicalize s_mask in fold_exts, fo


From: Pierrick Bouvier
Subject: Re: [PATCH v2 40/51] tcg/optimize: Canonicalize s_mask in fold_exts, fold_sextract
Date: Fri, 20 Dec 2024 12:19:33 -0800
User-agent: Mozilla Thunderbird

On 12/19/24 20:10, Richard Henderson wrote:
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;

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]