kobalicek / mathpresso

Mathematical Expression Parser and JIT Compiler
Other
141 stars 16 forks source link

Extra movsd's and some odd choice of register(s) #7

Open Zueuk opened 8 years ago

Zueuk commented 8 years ago

I noticed that the generated asm code loads the same value into the same register multiple times. The old Mathpresso (with an old AsmJit) version that I used before didn't do this:

x = y =1

lea rax, [L2] movsd xmm0, [rax] movsd [rdx], xmm0 movsd xmm0, [rax] movsd [rdx+8], xmm0 movsd xmm0, [rax] movsd [rcx], xmm0 ret

Another thing - a combination of an unary operation ("-", sqrt, etc.) and a function call somehow makes it use xmm6, that apparently needs to be savied/restored:

-x / sin(y)

sub rsp, 72 movaps oword ptr [rsp+48], xmm6 xorpd xmm6, xmm6 subsd xmm6, [rdx] ... movaps xmm6, oword ptr [rsp+48] add rsp, 72 ret

kobalicek commented 8 years ago

The best would be to have an implementation of all trigo functions inlinable, and this can be addressed in MathPresso as well. I'm planning to address the multiple fetches of constants in MPSL, I'm not sure if it is worth the effort to address it in MathPresso as it doesn't have IR (MSPL has).

kobalicek commented 8 years ago

I'm marking this as wontfix, as this will be fixed in more advanced MPSL project. After MPSL is ready there will be an expression mode so it can replace mathpresso completely.

kobalicek commented 7 years ago

Unnecessary MOVs will be also fixed by new asmjit's register allocator that can perform register coalescing, so no need to fix this in MathPresso.