Skip to content

implement missing cvt u64 -> r64 for x86-64  #37

Description

@robertmuth

since x86-64 does not have such an instruction (only one for s64 -> r64)
we should probably rewrite this at the IR level

cvt dst:r64 = src:u64

would become

if top bit of src:u64 is set:
shr dst2:u64 src:u64 1 # clears the top bit by halving the input
cvt dst3:s64 dst2:u64 # nop at the machine level
cvt dst:r64 dst3:s64 # use the available instruction
add dst:r64 dst:r64 dst:r64 # double the output
else:
cvt dst2:s64 dst:u64 # nop at the machine level
cvt dst:r64 dst2:s64 # use the available instruction

r64 only has about 52 significant bit so throwing one is no big deal

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions