On Mon, Aug 31, 2026 at 2:26 PM Avinal Kumar <[email protected]> wrote: > > The pattern that folds (X >> C1) & C2 and (X << C1) & C2 was limited > to types with precision <= HOST_BITS_PER_WIDE_INT because it used > unsigned HOST_WIDE_INT for mask and zerobits arithmetic. This prevents > the optimization from firing on __int128 and wider types at the GIMPLE > level. > > Convert the pattern to use wide_int and remove the TYPE_PRECISION guard. > Replace the mode-mask loop with wi::exact_log2 (newmask + 1) to check > whether newmask is (2^n - 1) for a power-of-two n >= BITS_PER_UNIT. > Handle the case where newmask is all-ones at full type precision > separately, since newmask + 1 overflows to zero in that case. > > PR120524 > PR tree-optimization/120524 > > gcc/ChangeLog: > > * match.pd: Use wide_int for shift-and-mask folding [PR120524] > > gcc/testsuite/ChangeLog: > > * gcc.dg/tree-ssa/pr120524.c: New test. > > Signed-off-by: Avinal Kumar <[email protected]> > ---
Hello all, gentle ping. Requesting for a review.
