Hello, I would like to know if there is an instruction to convert values from the Int1 type to the Double type in LLVM. I would like to achieve the equivalent of casting a bool value to a double value in C++. Doing the simple CreateSIToFP or CreateUIToFP does not work, it throws an assertion ("invalid cast"). I simply want to avoid branching it's not necessary. What's the simplest way to achieve this? Thank you for your time, - Max -- View this message in context: http://www.nabble.com/Int1-to-Double-Type-Conversion-tp23895625p23895625.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On Fri, Jun 5, 2009 at 2:15 PM, Nyx<mcheva at cs.mcgill.ca> wrote:> > Hello, > > I would like to know if there is an instruction to convert values from the > Int1 type to the Double type in LLVM. I would like to achieve the equivalent > of casting a bool value to a double value in C++. Doing the simple > CreateSIToFP or CreateUIToFP does not work, it throws an assertion ("invalid > cast"). I simply want to avoid branching it's not necessary. What's the > simplest way to achieve this?The following LLVM assembly seems to compile just fine: define double @a(i1 zeroext %x) nounwind { %rval = uitofp i1 %x to double ret double %rval } What does your code look like? -Eli
I'm simply using the IRBuilder, I call CreateUIToFP with the current value (llvm::Type::Int1Ty type), and pass the llvm::Type::DoubleTy as the destination type. This fails. I notice that your assembly has "zeroext" in the function parameter. Perhaps I need to create a "ZExt" instruction to extend the Int1 to an Int32 or something? -- View this message in context: http://www.nabble.com/Int1-to-Double-Type-Conversion-tp23895625p23902249.html Sent from the LLVM - Dev mailing list archive at Nabble.com.