Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- tcg/optimize.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tcg/optimize.c b/tcg/optimize.c index 22d302c9bf..5081e3db1f 100644 --- a/tcg/optimize.c +++ b/tcg/optimize.c @@ -2284,7 +2284,7 @@ static bool fold_or(OptContext *ctx, TCGOp *op) static bool fold_orc(OptContext *ctx, TCGOp *op) { - uint64_t s_mask; + uint64_t z_mask, o_mask, s_mask; TempOptInfo *t1, *t2; if (fold_const2(ctx, op) || @@ -2315,8 +2315,17 @@ static bool fold_orc(OptContext *ctx, TCGOp *op) } t1 = arg_info(op->args[1]); + + /* Affected bits are those not known one, masked by those known one. */ + if (fold_affected_mask(ctx, op, ~t1->o_mask & t2->o_mask)) { + return true; + } + + z_mask = t1->z_mask | ~t2->o_mask; + o_mask = t1->o_mask | ~t2->z_mask; s_mask = t1->s_mask & t2->s_mask; - return fold_masks_s(ctx, op, s_mask); + + return fold_masks_zos(ctx, op, z_mask, o_mask, s_mask); } static bool fold_qemu_ld_1reg(OptContext *ctx, TCGOp *op) -- 2.43.0