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

**URL:** https://discourse.julialang.org/t/llvm-vector-casting-bitcast-vector-4xi64-to-vector-8xi32/54757
**Category:** Internals & Design
**Created:** [February 6, 2021, 9:44pm UTC](https://discourse.julialang.org/t/llvm-vector-casting-bitcast-vector-4xi64-to-vector-8xi32/54757 "2021-02-06T21:44:44Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Rana\_Ian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rana_ian/32/13554_2.png) [@Rana\_Ian](https://discourse.julialang.org/u/Rana_Ian)
#### Post date: [February 6, 2021, 9:44pm UTC](https://discourse.julialang.org/t/llvm-vector-casting-bitcast-vector-4xi64-to-vector-8xi32/54757/1 "2021-02-06T21:44:44Z")

</div>

Hi,

Has anyone seen something like

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

[There’s an LLVM thread requesting to add those semantics](https://llvm.discourse.group/t/rfc-vector-standard-add-bitcast-operation/1628). 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.

---

<div class="post-metadata">

### Author: ![cgeoga](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgeoga/32/216186_2.png) [@cgeoga](https://discourse.julialang.org/u/cgeoga)
#### Post date: [February 6, 2021, 9:52pm UTC](https://discourse.julialang.org/t/llvm-vector-casting-bitcast-vector-4xi64-to-vector-8xi32/54757/2 "2021-02-06T21:52:05Z")

</div>

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

```julia
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](https://github.com/eschnett/SIMD.jl/blob/master/test/runtests.jl#L62).

---

<div class="post-metadata">

### Author: ![Rana\_Ian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rana_ian/32/13554_2.png) [@Rana\_Ian](https://discourse.julialang.org/u/Rana_Ian)
#### Post date: [February 6, 2021, 10:21pm UTC](https://discourse.julialang.org/t/llvm-vector-casting-bitcast-vector-4xi64-to-vector-8xi32/54757/3 "2021-02-06T22:21:52Z")

</div>

Thank you!

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

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

```
