Skip to contentSkip to conversation

tcg/optimize: Fix a_mask computation for orc

PATCH In review Richard Henderson 2 participants 3 messages Jan 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcg/optimize: Fix a_mask computation for orc

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.

Fixes cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
---
 tcg/optimize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/optimize.c +1 -1
index 23278799af..5ae26e4a10 100644
@@ -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);
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 16 lines · Richard Henderson

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.

Fixes cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
---
  tcg/optimize.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tcg/optimize.c +0 -0
index 23278799af..5ae26e4a10 100644

tcg/optimize.c static bool fold_orc(OptContext *ctx, TCGOp *op) · line 2366

Quoted 8 lines
tcg/optimize.c +1 -1
@@ -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~

Reviewed-by on v1 1/1
#2 lore raw
In reply to Richard Henderson
Quoted 11 lines · Richard Henderson

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.

Fixes cc4033ee47c ("tcg/optimize: Build and use zero, one and affected bits in fold_orc")
---
  tcg/optimize.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)