https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84321
--- Comment #10 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #8) > This seems to fix it. But as I said, the asserts still need to go. > > --- gcc/tree-ssanames.c.jj 2018-01-30 12:30:27.678359900 +0100 > +++ gcc/tree-ssanames.c 2018-02-12 11:32:51.768829381 +0100 > @@ -464,6 +464,21 @@ set_nonzero_bits (tree name, const wide_ > } > range_info_def *ri = SSA_NAME_RANGE_INFO (name); > ri->set_nonzero_bits (mask); > + /* If it is a range, try to improve min/max from nonzero_bits. */ > + if (SSA_NAME_RANGE_TYPE (name) == VR_RANGE) > + { > + wide_int msk = ri->get_nonzero_bits (); > + wide_int min = wi::round_up_for_mask (ri->get_min (), msk); > + wide_int max = wi::round_down_for_mask (ri->get_max (), msk); > + signop sgn = TYPE_SIGN (TREE_TYPE (name)); > + if (wi::le_p (min, max, sgn) > + && wi::le_p (min, ri->get_max (), sgn) > + && wi::le_p (ri->get_min (), max, sgn)) > + { > + ri->set_min (min); > + ri->set_max (max); > + } > + } > } > > /* Return a widest_int with potentially non-zero bits in SSA_NAME I'd tried doing this in set_nonzero_bits first, before adding intersect_range_with_nonzero_bits. See https://gcc.gnu.org/ml/gcc-patches/2018-02/msg00095.html for why it didn't work.