Simply or'ing the an input s_mask with the mask implied by
the sign extension operation may leave disconnected bits
to the right. Use smask_from_smask to canonicalize.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/optimize.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tcg/optimize.c b/tcg/optimize.c
index d0a9ea1ee4..8735dc0c9c 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1827,6 +1827,7 @@ static bool fold_exts(OptContext *ctx, TCGOp *op)
g_assert_not_reached();
}
s_mask |= sign << 1;
+ s_mask = smask_from_smask(s_mask);
if (!type_change && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
return true;
@@ -2534,8 +2535,13 @@ static bool fold_sextract(OptContext *ctx, TCGOp *op)
}
s_mask_old = t1->s_mask;
+ /*
+ * Use the sign mask from the input, force the repetitons from
+ * the sign extension operation, and canonicalize the result.
+ */
s_mask = sextract64(s_mask_old, pos, len);
s_mask |= MAKE_64BIT_MASK(len, 64 - len);
+ s_mask = smask_from_smask(s_mask);
if (pos == 0 && fold_affected_mask(ctx, op, s_mask & ~s_mask_old)) {
return true;