Trying to figure out what happens when I call “float_of_int” for native compilation to amd64 and arm64. I understand that the Cmm generated is roughly box_float (Cop(Cfloatofint (untag_int myfloat))). What does Cfloatofint get translated to?
box_float (Cop(Cfloatofint (untag_int myfloat)))
Underlying Motivation: Looking at how the fast pass of the Eisel-Lemire float parsing algorithm would look like in OCaml.
On amd64 it is translated into the sequence
amd64
sarq $1, %rax cvtsi2sdq %rax, %xmm0
where %rax contains the integer. The resulting double in %xmm0 may be boxed depending on the context.
%rax
%xmm0
I don’t have an arm64 machine at hand to try.
Cheers, Nicolas
(The sarq part is actually untag_int, not Cfloatofint) On Arm64 scvtf is used.
sarq
untag_int
Cfloatofint
scvtf
Thanks, indeed. I was rather thinking of float_of_int instead of Cfloattoint.
float_of_int
Cfloattoint