https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64182
--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> --- (In reply to rsand...@gcc.gnu.org from comment #3) > (In reply to Jakub Jelinek from comment #1) > > Created attachment 34222 [details] > > gcc5-pr64182.patch > > > > So like this (completely untested so far)? I'm hoping that remainder can't > > be ever for signed numbers equal to minimum signed value and thus hopefully > > wi::abs nor lshift of that by 1 should overflow. For UNSIGNED, not sure if > > wi::neg_p () is the right test for whether lshift by 1 will overflow. > > Looks OK to me, but I wonder if we could just use: > > wi::geu_p (y, remainder - y) > > for unsigned, and similarly with abses for signed, which avoids having to > worry about overflow. Will try. Er, of course I mean: wi::geu_p (remainder, y - remainder)