Re: Bug in divmodhi4(), plus poor inperformant code

2018-12-06 Thread Stefan Kanthak
"Segher Boessenkool" wrote: > On Wed, Dec 05, 2018 at 02:19:14AM +0100, Stefan Kanthak wrote: >> "Paul Koning" wrote: >> >> > Yes, that's a rather nasty cut & paste error I made. >> >> I suspected that. >> Replacing >> !(den & (1L<<31)) >> with >> (signed short) den >= 0 >> avoids

Re: Bug in divmodhi4(), plus poor inperformant code

2018-12-05 Thread Paul Koning
> On Dec 5, 2018, at 11:23 AM, Segher Boessenkool > wrote: > > On Wed, Dec 05, 2018 at 02:19:14AM +0100, Stefan Kanthak wrote: >> "Paul Koning" wrote: >> >>> Yes, that's a rather nasty cut & paste error I made. >> >> I suspected that. >> Replacing >>!(den & (1L<<31)) >> with >>

Re: Bug in divmodhi4(), plus poor inperformant code

2018-12-05 Thread Segher Boessenkool
On Wed, Dec 05, 2018 at 02:19:14AM +0100, Stefan Kanthak wrote: > "Paul Koning" wrote: > > > Yes, that's a rather nasty cut & paste error I made. > > I suspected that. > Replacing > !(den & (1L<<31)) > with > (signed short) den >= 0 > avoids this type of error: there's no need for a

Re: Bug in divmodhi4(), plus poor inperformant code

2018-12-05 Thread Paul Koning
> On Dec 4, 2018, at 8:19 PM, Stefan Kanthak wrote: > > "Paul Koning" wrote: > >> Yes, that's a rather nasty cut & paste error I made. > > I suspected that. > Replacing >!(den & (1L<<31)) > with >(signed short) den >= 0 > avoids this type of error: there's no need for a constant

Re: Bug in divmodhi4(), plus poor inperformant code

2018-12-04 Thread Stefan Kanthak
"Paul Koning" wrote: > Yes, that's a rather nasty cut & paste error I made. I suspected that. Replacing !(den & (1L<<31)) with (signed short) den >= 0 avoids this type of error: there's no need for a constant here! JFTR: of course the 1L should be just a 1, without suffix. > But if

Re: Bug in divmodhi4(), plus poor inperformant code

2018-12-04 Thread Paul Koning
Yes, that's a rather nasty cut & paste error I made. But if the 31 is changed to a 15, is the code correct? I would think so. For optimization I'd think that an assembly language version would make more sense, and a few targets do that. paul > On Dec 4, 2018, at 5:51 PM, Stefan

Bug in divmodhi4(), plus poor inperformant code

2018-12-04 Thread Stefan Kanthak
Hi @ll, libgcc's divmodhi4() function has an obvious bug; additionally it shows rather poor inperformant code: two of the three conditions tested in the first loop should clearly moved outside the loop! divmodsi4() shows this inperformant code too! regards Stefan Kanthak --- divmodhi4.c ---