Strange counter-performance in an alternative `decimalLength9` function
Basile B.
b2.temp at gmx.com
Thu Feb 27 04:44:56 UTC 2020
On Thursday, 27 February 2020 at 03:58:15 UTC, Bruce Carneal
wrote:
>>
>> Maybe you talked about another implementation of
>> decimalLength9 ?
>
> Yes. It's one I wrote after I saw your post. Psuedo-code here:
>
> auto d9_branchless(uint v) { return 1 + (v >= 10) + (v >=
> 100) ... }
>
> Using ldc to target an x86 with the above yields a series of
> cmpl, seta instruction pairs in the function body followed by a
> summing and a return. No branching.
>
> Let me know if the above is unclear or insufficient.
No thanks, it's crystal clear now.
More information about the Digitalmars-d-learn
mailing list