# compiler: implement better shuffle AIR · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/add2976a9ba76ec661ae5668eb2a8dca2ccfad42)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: add2976a9ba76ec661ae5668eb2a8dca2ccfad42

Requested commit: add2976a9ba76ec661ae5668eb2a8dca2ccfad42

Commit: add2976a9ba76ec661ae5668eb2a8dca2ccfad42

Tree: 54ea8377660395007c1ac5188863f5cbe3a3310e

Author: mlugg

Committer: mlugg

## Message

```
compiler: implement better shuffle AIR

Runtime `@shuffle` has two cases which backends generally want to handle
differently for efficiency:

* One runtime vector operand; some result elements may be comptime-known
* Two runtime vector operands; some result elements may be undefined

The latter case happens if both vectors given to `@shuffle` are
runtime-known and they are both used (i.e. the mask refers to them).
Otherwise, if the result is not entirely comptime-known, we are in the
former case. `Sema` now diffentiates these two cases in the AIR so that
backends can easily handle them however they want to. Note that this
*doesn't* really involve Sema doing any more work than it would
otherwise need to, so there's not really a negative here!

Most existing backends have their lowerings for `@shuffle` migrated in
this commit. The LLVM backend uses new lowerings suggested by Jacob as
ones which it will handle effectively. The x86_64 backend has not yet
been migrated; for now there's a panic in there. Jacob will implement
that before this is merged anywhere.

```

## Parents

- [b48d6ff619de424e664cf11b43e2a03fecbca6ce](https://git.cafe/gitcafe/zig/commit/b48d6ff619de424e664cf11b43e2a03fecbca6ce?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/add2976a9ba76ec661ae5668eb2a8dca2ccfad42?format=markdown)
