[LLVMdev] Multiply i8 operands promotes to i32
baldrick at free.fr
Mon Oct 8 03:00:54 PDT 2012
Hi Pedro, what is the "front-end" you refer to? Clang?
> I am trying to complete the hardware multiplier option for MSP430 backend.
> As the hardware multiplier in most of the MSP430 devices is for i8 and
> i16 operands, with i16 and i32 result, I am lowering MUL_i8 and MUL_I16.
> However, the front-end promotes the i8 argument to i32, executes 32-bit
> multiplier and truncates to 16-bit, so I never lower MUL_I8 nor MUL_I16
> but MUL_I32, wchich is lowered to an external libcall (__mulsi3) that I
> don´t have.
> What should I do in order to prevent the front-end from promote to
> 32-bit multiplier?
> If that is not possible, how can I detect when lowering that it is
> actually a MUL_I8 or MUL_I16 in order to do the correct lowering?
> Thanks in advance,
> P.S: I add C code and corresponding LLVM code.
> C code:
> (const u_int16_t in_data, u_int16_t* out)
> u_int8_t kk = in_data&0xFF;
> u_int16_t kk16 = kk * kk;
> *out = kk16;
> %1 = load i8* %kk, align 1
> %conv2 = zext i8 %1 to i32
> %2 = load i8* %kk, align 1
> %conv3 = zext i8 %2 to i32
> %mul = mul nsw i32 %conv2, %conv3
> %conv4 = trunc i32 %mul to i16
> store i16 %conv4, i16* %kk16, align 2
More information about the llvm-dev