diff mbox series

[41/46] tcg/optimize: Use fold_masks_zs in fold_xor

Message ID 20241210152401.1823648-42-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 | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Comments

Pierrick Bouvier Dec. 17, 2024, 8:45 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 | 17 +++++++----------
>   1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index 46116970f3..fec46014be 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -1093,11 +1093,6 @@ static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t z_mask)
>       return fold_masks_zsa(ctx, op, z_mask, smask_from_zmask(z_mask), -1);
>   }
>   
> -static bool fold_masks(OptContext *ctx, TCGOp *op)
> -{
> -    return fold_masks_zsa(ctx, op, ctx->z_mask, ctx->s_mask, ctx->a_mask);
> -}
> -

Not so important, but eliminating this function could be done in its own 
commit.

>   /*
>    * Convert @op to NOT, if NOT is supported by the host.
>    * Return true f the conversion is successful, which will still
> @@ -2758,6 +2753,8 @@ static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
>   
>   static bool fold_xor(OptContext *ctx, TCGOp *op)
>   {
> +    uint64_t z_mask, s_mask;
> +
>       if (fold_const2_commutative(ctx, op) ||
>           fold_xx_to_i(ctx, op, 0) ||
>           fold_xi_to_x(ctx, op, 0) ||
> @@ -2765,11 +2762,11 @@ static bool fold_xor(OptContext *ctx, TCGOp *op)
>           return true;
>       }
>   
> -    ctx->z_mask = arg_info(op->args[1])->z_mask
> -                | arg_info(op->args[2])->z_mask;
> -    ctx->s_mask = arg_info(op->args[1])->s_mask
> -                & arg_info(op->args[2])->s_mask;
> -    return fold_masks(ctx, op);
> +    z_mask = arg_info(op->args[1])->z_mask
> +           | arg_info(op->args[2])->z_mask;
> +    s_mask = arg_info(op->args[1])->s_mask
> +           & arg_info(op->args[2])->s_mask;
> +    return fold_masks_zs(ctx, op, z_mask, s_mask);
>   }
>   
>   static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Richard Henderson Dec. 18, 2024, 3:29 a.m. UTC | #2
On 12/17/24 14:45, Pierrick Bouvier wrote:
> On 12/10/24 07:23, Richard Henderson wrote:
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   tcg/optimize.c | 17 +++++++----------
>>   1 file changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/tcg/optimize.c b/tcg/optimize.c
>> index 46116970f3..fec46014be 100644
>> --- a/tcg/optimize.c
>> +++ b/tcg/optimize.c
>> @@ -1093,11 +1093,6 @@ static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t 
>> z_mask)
>>       return fold_masks_zsa(ctx, op, z_mask, smask_from_zmask(z_mask), -1);
>>   }
>> -static bool fold_masks(OptContext *ctx, TCGOp *op)
>> -{
>> -    return fold_masks_zsa(ctx, op, ctx->z_mask, ctx->s_mask, ctx->a_mask);
>> -}
>> -
> 
> Not so important, but eliminating this function could be done in its own commit.

No, we get a Werror for an unused function.


r~
diff mbox series

Patch

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 46116970f3..fec46014be 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1093,11 +1093,6 @@  static bool fold_masks_z(OptContext *ctx, TCGOp *op, uint64_t z_mask)
     return fold_masks_zsa(ctx, op, z_mask, smask_from_zmask(z_mask), -1);
 }
 
-static bool fold_masks(OptContext *ctx, TCGOp *op)
-{
-    return fold_masks_zsa(ctx, op, ctx->z_mask, ctx->s_mask, ctx->a_mask);
-}
-
 /*
  * Convert @op to NOT, if NOT is supported by the host.
  * Return true f the conversion is successful, which will still
@@ -2758,6 +2753,8 @@  static bool fold_tcg_st_memcopy(OptContext *ctx, TCGOp *op)
 
 static bool fold_xor(OptContext *ctx, TCGOp *op)
 {
+    uint64_t z_mask, s_mask;
+
     if (fold_const2_commutative(ctx, op) ||
         fold_xx_to_i(ctx, op, 0) ||
         fold_xi_to_x(ctx, op, 0) ||
@@ -2765,11 +2762,11 @@  static bool fold_xor(OptContext *ctx, TCGOp *op)
         return true;
     }
 
-    ctx->z_mask = arg_info(op->args[1])->z_mask
-                | arg_info(op->args[2])->z_mask;
-    ctx->s_mask = arg_info(op->args[1])->s_mask
-                & arg_info(op->args[2])->s_mask;
-    return fold_masks(ctx, op);
+    z_mask = arg_info(op->args[1])->z_mask
+           | arg_info(op->args[2])->z_mask;
+    s_mask = arg_info(op->args[1])->s_mask
+           & arg_info(op->args[2])->s_mask;
+    return fold_masks_zs(ctx, op, z_mask, s_mask);
 }
 
 static bool fold_bitsel_vec(OptContext *ctx, TCGOp *op)