diff mbox series

[07/46] tcg/optimize: Use fold_masks_zsa in fold_andc

Message ID 20241210152401.1823648-8-richard.henderson@linaro.org (mailing list archive)
State New
Headers show
Series tcg: Remove in-flight mask data from OptContext | expand

Commit Message

Richard Henderson Dec. 10, 2024, 3:23 p.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/optimize.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Comments

Pierrick Bouvier Dec. 17, 2024, 8:16 p.m. UTC | #1
On 12/10/24 07:23, Richard Henderson wrote:
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/optimize.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index 000ac0f810..285407ce05 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -1339,7 +1339,7 @@ static bool fold_and(OptContext *ctx, TCGOp *op)
>   
>   static bool fold_andc(OptContext *ctx, TCGOp *op)
>   {
> -    uint64_t z1;
> +    uint64_t z_mask, s_mask, a_mask = -1;
>   
>       if (fold_const2(ctx, op) ||
>           fold_xx_to_i(ctx, op, 0) ||
> @@ -1348,7 +1348,7 @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
>           return true;
>       }
>   
> -    z1 = arg_info(op->args[1])->z_mask;
> +    z_mask = arg_info(op->args[1])->z_mask;
>   
>       /*
>        * Known-zeros does not imply known-ones.  Therefore unless
> @@ -1356,14 +1356,13 @@ static bool fold_andc(OptContext *ctx, TCGOp *op)
>        */
>       if (arg_is_const(op->args[2])) {
>           uint64_t z2 = ~arg_info(op->args[2])->z_mask;
> -        ctx->a_mask = z1 & ~z2;
> -        z1 &= z2;
> +        a_mask = z_mask & ~z2;
> +        z_mask &= z2;
>       }
> -    ctx->z_mask = z1;
>   
> -    ctx->s_mask = arg_info(op->args[1])->s_mask
> -                & arg_info(op->args[2])->s_mask;
> -    return fold_masks(ctx, op);
> +    s_mask = arg_info(op->args[1])->s_mask
> +           & arg_info(op->args[2])->s_mask;
> +    return fold_masks_zsa(ctx, op, z_mask, s_mask, a_mask);
>   }
>   
>   static bool fold_brcond(OptContext *ctx, TCGOp *op)

I'm not sure eliminating z1 is worth the loss in readability here.

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

Patch

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 000ac0f810..285407ce05 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1339,7 +1339,7 @@  static bool fold_and(OptContext *ctx, TCGOp *op)
 
 static bool fold_andc(OptContext *ctx, TCGOp *op)
 {
-    uint64_t z1;
+    uint64_t z_mask, s_mask, a_mask = -1;
 
     if (fold_const2(ctx, op) ||
         fold_xx_to_i(ctx, op, 0) ||
@@ -1348,7 +1348,7 @@  static bool fold_andc(OptContext *ctx, TCGOp *op)
         return true;
     }
 
-    z1 = arg_info(op->args[1])->z_mask;
+    z_mask = arg_info(op->args[1])->z_mask;
 
     /*
      * Known-zeros does not imply known-ones.  Therefore unless
@@ -1356,14 +1356,13 @@  static bool fold_andc(OptContext *ctx, TCGOp *op)
      */
     if (arg_is_const(op->args[2])) {
         uint64_t z2 = ~arg_info(op->args[2])->z_mask;
-        ctx->a_mask = z1 & ~z2;
-        z1 &= z2;
+        a_mask = z_mask & ~z2;
+        z_mask &= z2;
     }
-    ctx->z_mask = z1;
 
-    ctx->s_mask = arg_info(op->args[1])->s_mask
-                & arg_info(op->args[2])->s_mask;
-    return fold_masks(ctx, op);
+    s_mask = arg_info(op->args[1])->s_mask
+           & arg_info(op->args[2])->s_mask;
+    return fold_masks_zsa(ctx, op, z_mask, s_mask, a_mask);
 }
 
 static bool fold_brcond(OptContext *ctx, TCGOp *op)