[Bug middle-end/64182] [5 Regression] wide-int rounding division is broken

rsandifo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 10 14:52:00 GMT 2014


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 rsandifo@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)



More information about the Gcc-bugs mailing list