On Friday, 23 December 2016 at 16:15:44 UTC, Andrei Alexandrescu
wrote:
An interesting problem to look at:
https://github.com/dlang/dmd/pull/6352
Andrei
Ok some hand written assembler to and-assign ints...
enum SIZE = 100000000;
void foo3(int* a, int* b)
{
asm
{
mov EAX,a;
mov EDX,b;
sub EDX,EAX;
mov ECX,EAX;
add ECX,SIZE*4;
l1:;
cmp EAX,ECX;
jae done;
mov EBX,[EAX];
and EBX,[EAX+EDX];
mov [EAX],EBX;
add EAX,4;
jmp l1;
done:;
}
}
I get..
456ms for unconditional
505ms for conditional
268ms for assembler
So the asm is about 40% faster than the best of the alternatives.
The point being that it's the generated code not the source
that's the problem.