# How to emit vunpck instruction

**URL:** <https://ziggit.dev/t/how-to-emit-vunpck-instruction/17814>\
**Category:** Help\
**Tags:** language, compiler\
**Created:** [October 3, 2026, 12:27pm UTC](https://ziggit.dev/t/how-to-emit-vunpck-instruction/17814 "2026-10-03T12:27:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ODON1](https://ziggit.dev/letter_avatar_proxy/v4/letter/o/94ad74/32.png) [@ODON1](https://ziggit.dev/u/ODON1)\
**Post date:** [October 3, 2026, 12:27pm UTC](https://ziggit.dev/t/how-to-emit-vunpck-instruction/17814/1 "2026-10-03T12:27:47Z")

</div>

Does anyone know if it is possible to have zig emit vunpck[hl][pd|ps] etc. instructions?

Everything i try is being compiled to two permutes and a blend

```zig
        push rbp
        mov rbp, rsp
        vpermpd ymm0, ymmword ptr [rsi], 96
        vpermpd ymm1, ymmword ptr [rdi], 212
        vblendps ymm0, ymm1, ymm0, 204
        vmovups ymmword ptr [rdx], ymm0
        pop rbp
        vzeroupper
        ret

```

Maybe i seeing thing wrong but thats 3 uops with a latency of 5 wheres a vunpck instruction would be 1 uop with latency 1.

I tried using @“llvm” intrinsics but in there i cannot find unpck instructions for avx2 (only mmx). Are they not implemented or something?

Also in doc/langref/destructuring\_vectors.zig there is:

```zig
// emulate punpckldq
pub fn unpack(x: @Vector(4, f32), y: @Vector(4, f32)) @Vector(4, f32) {
    const a, const c, _, _ = x;
    const b, const d, _, _ = y;
    return .{ a, b, c, d };
}

```

but this gives me the aformentioned assembly output.

---

<div class="post-metadata">

**Author:** ![rpkak](https://ziggit.dev/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@rpkak](https://ziggit.dev/u/rpkak)\
**Post date:** [October 3, 2026, 12:57pm UTC](https://ziggit.dev/t/how-to-emit-vunpck-instruction/17814/2 "2026-10-03T12:57:56Z")

</div>

Try to use [`@shuffle`](https://ziglang.org/documentation/master/#shuffle). Not sure it always works, but this [compiles](https://zig.godbolt.org/z/MPr711Koj) to a `vunpcklps` instruction:

```zig
export fn unpack(x: @Vector(4, f32), y: @Vector(4, f32)) @Vector(4, f32) {
    return @shuffle(f32, x, y, [_]i32{ 0, -1, 1, -2 });
}

```

---

<div class="post-metadata">

**Author:** ![ODON1](https://ziggit.dev/letter_avatar_proxy/v4/letter/o/94ad74/32.png) [@ODON1](https://ziggit.dev/u/ODON1)\
**Post date:** [October 3, 2026, 2:01pm UTC](https://ziggit.dev/t/how-to-emit-vunpck-instruction/17814/3 "2026-10-03T14:01:25Z")

</div>

I’am sure i tried that as the first thing! Must have been sleeping at the time or so.  
Thanks

(edit)  
I see i was testing f64.  
Then it still emits permpd’s

 ![image](https://ziggit.dev/uploads/default/original/2X/5/58eb0db127f0694810aa2fc3f4038abf2d882708.png)
