[LLVMdev] Convert a vector size

Tim Northover t.p.northover at gmail.com
Fri May 4 12:18:16 PDT 2012


> Is it possible to convert a vectors from different size? For example
> a vector of 3 elements Int16Ty type to vector having one element of
> 64 bit Int64Ty ?

Not with a bitcast. You'd probably use a shuffle followed by a bitcast for that:

%temp = shufflevector <3 x i16> %incoming, <3 x i16> undef, <4 x i32>
<i32 0, i32 1, i32 2, i32 undef>
%out = bitcast <4 x i16> %temp to i64

This creates a vector with its first elements the <3 x i16> and its
last element undefined, which *can* be bitcast.

Of course, the real question is why you want to do this: any solution
is going to have nasty issues around: endianness, legal types, more
stuff I haven't considered. Exactly how do you want the incoming <3 x
i16> to contribute to the i64? A slightly eccentric answer to that
question would make my code sequence horribly wrong.

Tim.



More information about the llvm-dev mailing list