[LLVMdev] Why BinaryOperator::Create requires same argument types for shifts?

Yuri yuri at rawbw.com
Fri Aug 26 12:51:34 PDT 2011


On 08/26/2011 05:32, Stephan Falke wrote:
> As stated in LLVM's language reference manual
> (http://llvm.org/docs/LangRef.html#i_shl), both arguments for a shl need
> to have the same type.

In my case, original types were uint8 (value) and uint32 (shift)
llvm lacks unsigned types which made it S1=i8 and S2=i32. It's 
technically nothing wrong with such combination, and code works fine 
until I ran debug llvm for some other reason and this assert showed up.

So if I need to shift signed int8 with unsigned uint32, I have to first 
truncate shift to uint8, with understanding that uint8 will become int8 
because llvm lacks unsignedness?
I think such requirement is redundant and you should make an exception 
in shift operator definitions to allow for any combination of numeric 
arguments. It forces to create an extra trunc/expand operator without 
the real need.

Yuri



More information about the llvm-dev mailing list