On 12/10/24 07:23, Richard Henderson wrote:
Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
  tcg/optimize.c | 15 +++++++--------
  1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 551f96dfaa..bec5a07288 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -2530,12 +2530,12 @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
      if (arg_is_const(op->args[2])) {
          int sh = arg_info(op->args[2])->val;
- ctx->z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
+        z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh);
s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh);
-        ctx->s_mask = smask_from_smask(s_mask);
+        s_mask = smask_from_smask(s_mask);
- return fold_masks(ctx, op);
+        return fold_masks_zs(ctx, op, z_mask, s_mask);
      }
switch (op->opc) {
@@ -2544,23 +2544,22 @@ static bool fold_shift(OptContext *ctx, TCGOp *op)
           * Arithmetic right shift will not reduce the number of
           * input sign repetitions.
           */
-        ctx->s_mask = s_mask;
-        break;
+        return fold_masks_zs(ctx, op, -1, s_mask);
      CASE_OP_32_64(shr):
          /*
           * If the sign bit is known zero, then logical right shift
-         * will not reduced the number of input sign repetitions.
+         * will not reduce the number of input sign repetitions.
           */
          sign = (s_mask & -s_mask) >> 1;
          if (sign && !(z_mask & sign)) {
-            ctx->s_mask = s_mask;
+            return fold_masks_zs(ctx, op, -1, s_mask);
          }
          break;
      default:
          break;
      }
- return false;
+    return finish_folding(ctx, op);
  }
static bool fold_sub_to_neg(OptContext *ctx, TCGOp *op)

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


Reply via email to