[LLVMdev] Int1 to Double Type Conversion

Eli Friedman eli.friedman at gmail.com
Fri Jun 5 15:08:02 PDT 2009


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



More information about the llvm-dev mailing list