(define thing 0 1 -> 2 0 y -> 3 1 0 -> 4 1 x -> (+ x 5) y z -> (+ y z) ) (thing 10 20)Which turned into a nice set of if statements, doing 4 tests in total. Not bad. But I was curious to see what kind of asm LLVM would generate for it.
_vm:
Leh_func_begin7:
pushq %rbp
Llabel13:
movq %rsp, %rbp
Llabel14:
movq _heap0(%rip), %rax
movq $772, (%rax)
movq $10, 8(%rax)
movq $10, 16(%rax)
movq $1, 24(%rax)
movl $61, %eax
popq %rbp
ret
Leh_func_end7:
Huh. So that bit there at the very end, "movl $61, %eax". Yeah. That's the answer, "30". Even with all the tagging/untagging, registers, embedded if statements, etc... LLVM still optimized the entire program away to a constant. Nice.

1 comments: