diff mbox series

[38/46] tcg/optimize: Use finish_folding in fold_sub, fold_sub_vec

Message ID 20241210152401.1823648-39-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
Duplicate fold_sub_vec into fold_sub instead of calling it,
now that fold_sub_vec always returns true.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/optimize.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Pierrick Bouvier Dec. 17, 2024, 8:44 p.m. UTC | #1
On 12/10/24 07:23, Richard Henderson wrote:
> Duplicate fold_sub_vec into fold_sub instead of calling it,
> now that fold_sub_vec always returns true.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/optimize.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index bec5a07288..6412d5df37 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -2606,12 +2606,15 @@ static bool fold_sub_vec(OptContext *ctx, TCGOp *op)
>           fold_sub_to_neg(ctx, op)) {
>           return true;
>       }
> -    return false;
> +    return finish_folding(ctx, op);
>   }
>   
>   static bool fold_sub(OptContext *ctx, TCGOp *op)
>   {
> -    if (fold_const2(ctx, op) || fold_sub_vec(ctx, op)) {
> +    if (fold_const2(ctx, op) ||
> +        fold_xx_to_i(ctx, op, 0) ||
> +        fold_xi_to_x(ctx, op, 0) ||
> +        fold_sub_to_neg(ctx, op)) {
>           return true;
>       }
>   
> @@ -2623,7 +2626,7 @@ static bool fold_sub(OptContext *ctx, TCGOp *op)
>                      ? INDEX_op_add_i32 : INDEX_op_add_i64);
>           op->args[2] = arg_new_constant(ctx, -val);
>       }
> -    return false;
> +    return finish_folding(ctx, op);
>   }
>   
>   static bool fold_sub2(OptContext *ctx, TCGOp *op)

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

Patch

diff --git a/tcg/optimize.c b/tcg/optimize.c
index bec5a07288..6412d5df37 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -2606,12 +2606,15 @@  static bool fold_sub_vec(OptContext *ctx, TCGOp *op)
         fold_sub_to_neg(ctx, op)) {
         return true;
     }
-    return false;
+    return finish_folding(ctx, op);
 }
 
 static bool fold_sub(OptContext *ctx, TCGOp *op)
 {
-    if (fold_const2(ctx, op) || fold_sub_vec(ctx, op)) {
+    if (fold_const2(ctx, op) ||
+        fold_xx_to_i(ctx, op, 0) ||
+        fold_xi_to_x(ctx, op, 0) ||
+        fold_sub_to_neg(ctx, op)) {
         return true;
     }
 
@@ -2623,7 +2626,7 @@  static bool fold_sub(OptContext *ctx, TCGOp *op)
                    ? INDEX_op_add_i32 : INDEX_op_add_i64);
         op->args[2] = arg_new_constant(ctx, -val);
     }
-    return false;
+    return finish_folding(ctx, op);
 }
 
 static bool fold_sub2(OptContext *ctx, TCGOp *op)