Skip to content

Compilation for Miri selects unsupported intrinsics #524

@nazar-pc

Description

@nazar-pc

I tried this code:

pub fn xperm8(rs1: u64, rs2: u64) -> u64 {
    use core::simd::u8x8;

    let lut = u8x8::from_array(rs1.to_le_bytes());
    let idx = u8x8::from_array(rs2.to_le_bytes());

    let result = lut.swizzle_dyn(idx);

    u64::from_le_bytes(result.to_array())
}

https://github.com/nazar-pc/abundance/blob/8d58514ebed9513c3a23370517f8cc3742ea0fa3/crates/execution/ab-riscv-interpreter/src/rv64/zk/zbkx/rv64_zbkx_helpers.rs#L35-L52

Reproducible in the repo at that commit with:

cd crates/execution/ab-riscv-interpreter
cargo miri test --target aarch64-apple-darwin -- rv64::zk::zbkx::tests::test_xperm8_basic

I expected to see this happen:

Calling this function under Miri should succeed on all platforms.

Instead, this happened:

On Aarch64 many intrinsics are currently not supported, yet core::simd attempts to use them anyway, resulting in this:

test rv64::zk::zbkx::tests::test_xperm8_basic ... error: unsupported operation: can't call foreign function `llvm.aarch64.neon.tbl1.v8i8` on OS `macos`
     --> /home/nazar-pc/.rustup/toolchains/nightly-2026-04-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/generated.rs:19109:14
      |
19109 |     unsafe { _vqtbl1(a, b) }
      |              ^^^^^^^^^^^^^ unsupported operation occurred here
      |
      = help: this means the program tried to do something Miri does not support; it does not indicate a bug in the program
      = note: this is on thread `rv64::zk::zbkx::tests::test_xperm8_basic`
      = note: stack backtrace:
              0: core::core_arch::aarch64::neon::generated::vqtbl1
                  at /home/nazar-pc/.rustup/toolchains/nightly-2026-04-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/generated.rs:19109:14: 19109:27
              1: core::arch::aarch64::vqtbl1_u8
                  at /home/nazar-pc/.rustup/toolchains/nightly-2026-04-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/generated.rs:19152:24: 19152:47
              2: core::arch::aarch64::vtbl1_u8
                  at /home/nazar-pc/.rustup/toolchains/nightly-2026-04-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/aarch64/neon/generated.rs:25782:5: 25782:66
              3: core::core_simd::swizzle_dyn::transize::<core::arch::aarch64::uint8x8_t, 8>
                  at /home/nazar-pc/.rustup/toolchains/nightly-2026-04-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../portable-simd/crates/core_simd/src/swizzle_dyn.rs:186:35: 186:86
              4: core::core_simd::swizzle_dyn::<impl core::simd::Simd<u8, 8>>::swizzle_dyn
                  at /home/nazar-pc/.rustup/toolchains/nightly-2026-04-11-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../portable-simd/crates/core_simd/src/swizzle_dyn.rs:48:22: 48:52
              5: rv64::zk::zbkx::rv64_zbkx_helpers::xperm8
                  at crates/execution/ab-riscv-interpreter/src/rv64/zk/zbkx/rv64_zbkx_helpers.rs:47:26: 47:46
              6: rv64::zk::zbkx::<impl ExecutableInstruction<basic::BasicRegisters<ab_riscv_primitives::prelude::Reg<u64>>, rv64::test_utils::ExtState, rv64::test_utils::TestMemory, rv64::test_utils::TestInstructionFetcher<ab_riscv_primitives::prelude::Rv64ZbkxInstruction<ab_riscv_primitives::prelude::Reg<u64>>>, rv64::test_utils::TestInstructionHandler> for ab_riscv_primitives::prelude::Rv64ZbkxInstruction<ab_riscv_primitives::prelude::Reg<u64>>>::execute
                  at /home/nazar-pc/.cache/cargo/target/miri/aarch64-apple-darwin/debug/build/ab-riscv-interpreter-bd29c561832f6dd1/out/Rv64ZbkxInstruction_execution_impl.rs:40:32: 40:79
              7: rv64::test_utils::execute::<ab_riscv_primitives::prelude::Rv64ZbkxInstruction<ab_riscv_primitives::prelude::Reg<u64>>>
                  at crates/execution/ab-riscv-interpreter/src/rv64/test_utils.rs:515:15: 521:10
              8: rv64::zk::zbkx::tests::test_xperm8_basic
                  at crates/execution/ab-riscv-interpreter/src/rv64/zk/zbkx/tests.rs:94:5: 94:24
              9: rv64::zk::zbkx::tests::test_xperm8_basic::{closure#0}
                  at crates/execution/ab-riscv-interpreter/src/rv64/zk/zbkx/tests.rs:82:23: 82:23

It'd be really nice if core:simd was aware of this and used software fallback automatically for unsupported intrinsics.

Meta

rustc --version --verbose:

rustc 1.96.0-nightly (02c7f9bec 2026-04-10)
binary: rustc
commit-hash: 02c7f9bec0fd583160f8bcccb830216023b07bee
commit-date: 2026-04-10
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions