[LLVMdev] convert integer to double "uitofp" or "sitofp" ?

Duncan Sands baldrick at free.fr
Fri Oct 21 04:00:01 PDT 2011


Hi Jimborean,

> As I understand, in LLVM IR it cannot be determined whether a register of type
> int is signed or unsigned.
> If one wants to convert an integer to a double, which instruction should be
> used: "uitofp" or "sitofp" ?

LLVM integers are just bags of bits, so this can't be answered without more
information about what you plan to do with the double.  Using an uitofp is no
more or less sensible than using sitofp in general.  What if your integer can't
be accurately represented by a double?  For example i64 -> double -> i64
(Xitofp followed by fptoXi) may not get you your original integer back.  Do
you care?  You can also bitcast an i64 to a double, getting a double that has
the same bit pattern.  But then does converting to a double win you anything?

> We track the values taken by all load instructions and we process them using a
> function.

What does the function do?

Ciao, Duncan.



More information about the llvm-dev mailing list