On Wed, Oct 14, 2015 at 08:54:11PM +0200, Marc Glisse wrote: > On Wed, 14 Oct 2015, Marek Polacek wrote: > > >Evidently, the X - (X / Y) * Y -> X % Y pattern can't change the > >signedness of X from signed to unsigned, otherwise we'd generate > >wrong code. (But unsigned -> signed should be fine.) > > > >Does anyone see a better fix than this? > > I was wondering about producing: > > (convert (trunc_mod @0 @1))
That's exactly what we had before r225195. > Aren't there also problems if the conversion changes the precision? I can > imagine your patch ending in x % 0, with @1 non-zero but a narrowing cast. Hmm, I haven't found such a case yet. If you find something, pass it along ;). Marek