dplassgit / d2lang

D2 is a strongly-typed, statically-typed, (mostly) inferred-type compiled language.
MIT License
7 stars 0 forks source link

Too many temps are used #167

Closed dplassgit closed 2 years ago

dplassgit commented 2 years ago

If a temp is the binary combination of two other temps, it can just reuse one of them.

E.g.,

; GENERATE: __temp616 = __temp614 * __temp615
; Allocating __temp616 to XMM6
movsd XMM6, XMM5 ; double setup
mulsd XMM6, XMM4 ; double *
; Deallocating __temp614 from XMM5
; Deallocating __temp615 from XMM4

the mov xmm6, xmm5 isn't needed, it could probably just be mulsd xmm5, xmm4

This applies to integer too.

dplassgit commented 2 years ago

Ah, but the NEXT op that was going to use __temp616 has to instead use __temp614