[LLVMdev] Need help in converting int to double

Duncan Sands baldrick at free.fr
Fri Sep 23 00:39:27 PDT 2011

Hi James,

> The docs are slightly hazy on that - they do mention type-to-type if same size, but the examples are only between pointers and integers, not floats.

you can't use bitcast to convert a pointer to an integer or vice-versa.  You
must use ptrtoint/inttoptr.

Ciao, Duncan.

  Would it be worthwhile my updating the documentation to explicitly state that 
or is it just me?
> Cheers,
> James
> -----Original Message-----
> From: John McCall [mailto:rjmccall at apple.com]
> Sent: 23 September 2011 00:06
> To: James Molloy
> Cc: sarath chandra; llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] Need help in converting int to double
> On Sep 22, 2011, at 3:32 AM, James Molloy wrote:
>> It's in trouble by this point because it needs to do a fptosi on a double operand, but you've got an i64 operand and you can't reinterpret-cast ints to floats in LLVM IR (AFAIK)
> You can bitcast ints to floats and vice-versa if they're the same size - for example, i32 to float and i64 to double.
> John.
> -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list