[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (work2) now available
- From: Tim Hill <drtimhill@...>
- Date: Wed, 26 Mar 2014 14:45:46 -0700
On Mar 26, 2014, at 9:41 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>> Let’s be clear, arithmetic shift is a useful tool as a low-level
>> operation for more than just shorthand division — this is the
>> reason it exists as a basic operation in every mainstream CPU
>> architecture. I’ve used it over the years for the signum function
>> (where is works very well indeed) optimized bit-counting etc etc. It
>> should be noted that almost all these uses are where performance is
>> hyper-critical.
>
> Just for curiosity, do you remember those techniques?
>
> -- Roberto
>
I’m a bit ashamed to say that i do lol. Signum for example:
static inline int sgn2(int x) { return (x != 0) * (1 | (x >> ((sizeof(x) * 8) - 1))); }
The code generated has only one conditional branch … significant on a non super-scalar CPU.
Mostly of course these are techniques used in assembly language “poking through” into C.
—Tim
- References:
- [ANN] Lua 5.3.0 (work2) now available, Luiz Henrique de Figueiredo
- Re: [ANN] Lua 5.3.0 (work2) now available, Paul Baker
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Coda Highland
- Re: [ANN] Lua 5.3.0 (work2) now available, Dirk Laurie
- Re: [ANN] Lua 5.3.0 (work2) now available, Coda Highland
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy
- Re: [ANN] Lua 5.3.0 (work2) now available, Tim Hill
- Re: [ANN] Lua 5.3.0 (work2) now available, Enrico Colombini
- Re: [ANN] Lua 5.3.0 (work2) now available, Tim Hill
- Re: [ANN] Lua 5.3.0 (work2) now available, Roberto Ierusalimschy