Reducing the cost of autodecoding

safety0ff via Digitalmars-d digitalmars-d at puremagic.com
Wed Oct 12 13:02:16 PDT 2016


On Wednesday, 12 October 2016 at 16:24:19 UTC, Andrei 
Alexandrescu wrote:
>
> Remember the ASCII part is the bothersome one. There's only two 
> comparisons, all with 100% predictability. We should be able to 
> arrange matters so the loss is negligible. -- Andrei

My measurements:
ldc -O3  -boundscheck=off -release -mcpu=native -enable-inlining
ldc version 1.0.0

overhead 0.350s
bytes    0.385s
current autodecoding 0.915s (with new LUT popFront)
copy-pasting std.utf decoding functions into current file 0.840s
adding ASCII branch hints (llvm_expect) 0.770s

With the branch hints LDC moves the non-Ascii code outside of the 
loop and creates a really tight loop body.


More information about the Digitalmars-d mailing list