When we type an integer literal like 5, it'll often codegen into a (fromInt 5) call to allow integers to represent a broad collection of numerical types without programmer effort.
However, this translation happens at run-time, causing even simple loops to be sometimes 2-10x slower with copious allocation.
A "proper" solution to this problem would be to have more mature compiler passes so that we get this optimization "for free". But this is a common case and is very low-hanging fruit.
Note that it's likely the folded value will need to be *PRINT-READABLY* since it will be written out into compiled Lisp code. Therefore we may restrict this optimization to standard numerical types: ints and floats.
When we type an integer literal like
5
, it'll often codegen into a(fromInt 5)
call to allow integers to represent a broad collection of numerical types without programmer effort.However, this translation happens at run-time, causing even simple loops to be sometimes 2-10x slower with copious allocation.
A "proper" solution to this problem would be to have more mature compiler passes so that we get this optimization "for free". But this is a common case and is very low-hanging fruit.
Note that it's likely the folded value will need to be
*PRINT-READABLY*
since it will be written out into compiled Lisp code. Therefore we may restrict this optimization to standard numerical types: ints and floats.