Mail Archives: djgpp-workers/2000/05/23/08:32:49
On 23 May 00, Eli Zaretskii wrote:
> On Tue, 23 May 2000, Dieter Buerssner wrote:
> > On 23 May 00, at 12:06, Eli Zaretskii wrote:
> > > The code seems consistent with C9X draft, as far as I could see, but
> > > isn't it better to replace it with inline asm that does this in a
> > > single instruction?
> >
> > Gcc will usually produce only one idiv instruction for n/d; n%d pairs
> > for integer types smaller long long.
>
> First, I meant the long long version as well.
It would be a rather difficult task, to write the long long version
with inline assembly. You have to take into account, that the
demoniator is > 32 bits. There is no upcode for this. Even, when the
demoniator is smaller 32 bits, idiv won't be enough, because the
result can overflow. I think, one has just to live with the fact,
that long long / long long and long long % long long will be a rather
slow operation with x86.
> And second, I was thinking
> about putting a fast inline version into stdlib.h as a macro, and making
> the function versions use that macro as their body. We do that for getc
> and putc, for example.
While it might be a good idea, to use an inline version,I don't see
any need, to use inline assembly for it.
As a side note, I think these functions will loose importance. In
C99, % and / are well defined for negative numbers. This was not the
case in C90.
Regards,
Dieter
- Raw text -