[fpc-devel] bitshift intrinsics

Marco van de Voort marcov at stack.nl
Fri Oct 14 14:25:44 CEST 2016


In our previous episode, Jonas Maebe said:
> > If the dword version returned $FFFFFFFF it could be at least typecasted to
> > -1.
> 
> You can typecast the result to shortint to get -1 in that case.

That removes the additional branch, reducing it to a movsbl, so I assume the
resulting code is better, thanks.
 
> > So the questions are:
> > 1. why do the primitives deliver a signed result ?
> 
> *unsigned

True, but question still stands. Anyway, I'll wait if FLorian recollects
anything.

> > 3. (for Michael: :-) why doesn't the documentation doesn't mention the
> > behaviour for no bits set?).
> >
> > Since (3) the behaviour is not documented, we can still fix this ? :-)
> 
> They've behaved like this since FPC 2.6.0, so no.

Looking at the generic (non cpu) version with the lookup table, the reason
for $ff becomes somewhat logical. It is bytewise, and $FF is the value of 0
in the per byte table. 

Anyway, I just wanted to avoid floating point in the original case, and it
was not really extremely speeddependent. I just wondered.

I've filed a doc bug 30740 so that at least something good comes out of it.




More information about the fpc-devel mailing list