How to simply add boolean to int16

Hello I am trying to write very simple loop in the LLVM
I get 3 arguments 0) boolean [i8] 1)boollean [i8] 2) Int16 [i16] and return Int 16 [i16]
I want to return the third argument incremented by 1 if both 1 and 2 are true
I am new to LLVM - possibly I need to allocate some memory here?

below what I try, but neither “and” nor “bitcast works”

                %4= and %0 %1
                %5=bitcast i8 %4 to i16
                %6 = add i16 %2,%4
                ret i16 %6

Thanks for Help !!!

You want zext to zero-extend the bool to i16:

 %4 = and i8 %0, %1
 %5 = zext i8 %4 to i16
 %6 = add i16 %2,%5
 ret i16 %6

(because bitcast can only cast between types of the same size).

1 Like

Thank You for a response, it works! Additionaly I can not find not gate - I am able to get around with XOR and AND but simple boolean negation would be usefull
Thank You!