Int1 to Double Type Conversion


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

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?


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