LLVM vector casting? bitcast … vector<4xi64> to vector<8xi32>

Hi,

Has anyone seen something like

bitcast … vector<4xi64> to vector<8xi32>

There’s an LLVM thread requesting to add those semantics. So, it doesn’t seem to be available in that form. But I thought I would ask here in case anyone knows a similar approach that could be nearly as fast.

I’m no expert here, but SIMD.jl provides vector types, and you could potentially use reinterpret or something:

using SIMD
x = Vec{4, Int64}(0)
y = reinterpret(Vec{8, Int32}, x)

I don’t really know enough to write some sensible test which suggests that this has the behavior you want, but presumably something like this is the closest analog to what you’re describing. Hopefully somebody else can step in and be more helpful.

EDIT: Oh hey, look at that! This does seem to be something that SIMD.jl is thinking about.

3 Likes

Thank you!

Just what I needed, and essentially the same thing with some minor overhead.

@code_llvm reinterpret(Vec{8, Int32}, x)
...
%2 = bitcast [1 x <4 x i64>]* %1 to <8 x i32>*
...
1 Like