Re: [PULL 02/38] tcg/optimize: Fix s_mask computation for shifts
Michael Tokarev <[email protected]>
| Newsgroups | org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
On 8/18/26 20:01, Richard Henderson wrote: > Skip s_mask computation for logical right shift. > > Cc: [email protected] > Fixes: 93a967fbb57 ("tcg/optimize: Propagate sign info for shifting") > Reported-by: Jacob Young <[email protected]> > Signed-off-by: Richard Henderson <[email protected]> > --- > tcg/optimize.c | 11 ++++++++++- > tests/tcg/i386/test-i386-opt-shr.c | 21 +++++++++++++++++++++ > 2 files changed, 31 insertions(+), 1 deletion(-) > create mode 100644 tests/tcg/i386/test-i386-opt-shr.c > > diff --git a/tcg/optimize.c b/tcg/optimize.c > index ed2ff32ed2..d12babad88 100644 > --- a/tcg/optimize.c > +++ b/tcg/optimize.c > @@ -2656,8 +2656,17 @@ static bool fold_shift(OptContext *ctx, TCGOp *op) > > z_mask = do_constant_folding(op->opc, ctx->type, z_mask, sh); > o_mask = do_constant_folding(op->opc, ctx->type, o_mask, sh); > - s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh); > > + if (op->opc == INDEX_op_shr) { > + /* > + * Logical right shift will force the sign bit zero. > + * Don't bother computing s_mask and let fold_masks > + * recompute from z_mask. > + */ > + return fold_masks_zo(ctx, op, z_mask, o_mask); > + } > + > + s_mask = do_constant_folding(op->opc, ctx->type, s_mask, sh); In 10.0.x, things are (were) a bit different. Does this back-port look sane? -- https://gitlab.com/mjt0k/qemu/-/commit/77ad6491326b4d0b2907f0ed9d504d6f490e245c Thanks, /mjt