[PATCH] tcg/optimize: Fix a_mask computation for orc

Richard Henderson posted 1 patch 4 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260111071137.433005-1-richard.henderson@linaro.org
Maintainers: Richard Henderson <richard.henderson@linaro.org>
tcg/optimize.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tcg/optimize: Fix a_mask computation for orc
Posted by Richard Henderson 4 weeks, 1 day ago
In computing a_mask, for or, we remove the bits from t1->o_mask
which are known to be zero.  For orc, the bits known to be zero
are the inverse of those known to be one.

Cc: qemu-stable@nongnu.org
Fixes: cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tcg/optimize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 23278799af..5ae26e4a10 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -2360,7 +2360,7 @@ static bool fold_orc(OptContext *ctx, TCGOp *op)
     s_mask = t1->s_mask & t2->s_mask;
 
     /* Affected bits are those not known one, masked by those known one. */
-    a_mask = ~t1->o_mask & t2->o_mask;
+    a_mask = ~t1->o_mask & ~t2->o_mask;
 
     return fold_masks_zosa(ctx, op, z_mask, o_mask, s_mask, a_mask);
 }
-- 
2.43.0
Re: [PATCH] tcg/optimize: Fix a_mask computation for orc
Posted by Pierrick Bouvier 4 weeks ago
On 1/10/26 11:11 PM, Richard Henderson wrote:
> In computing a_mask, for or, we remove the bits from t1->o_mask
> which are known to be zero.  For orc, the bits known to be zero
> are the inverse of those known to be one.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/optimize.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Re: [PATCH] tcg/optimize: Fix a_mask computation for orc
Posted by Richard Henderson 4 weeks, 1 day ago
On 1/11/26 18:11, Richard Henderson wrote:
> In computing a_mask, for or, we remove the bits from t1->o_mask
> which are known to be zero.  For orc, the bits known to be zero
> are the inverse of those known to be one.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   tcg/optimize.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index 23278799af..5ae26e4a10 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -2360,7 +2360,7 @@ static bool fold_orc(OptContext *ctx, TCGOp *op)
>       s_mask = t1->s_mask & t2->s_mask;
>   
>       /* Affected bits are those not known one, masked by those known one. */
> -    a_mask = ~t1->o_mask & t2->o_mask;
> +    a_mask = ~t1->o_mask & ~t2->o_mask;
>   
>       return fold_masks_zosa(ctx, op, z_mask, o_mask, s_mask, a_mask);
>   }

I meant to mention, that this bug is exposed by Paolo's fix to actually make use of 
a_mask: tests/tcg/hexagon/hvx_misc fails.


r~