portable-simd's swizzle_dyn miscompiles on x86-64 #119904
Labels
A-SIMD
Area: SIMD (Single Instruction Multiple Data)
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
PG-portable-simd
Project group: Portable SIMD (https://github.com/rust-lang/project-portable-simd)
requires-nightly
This issue requires a nightly compiler in some way.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
I tried this code:
I expected to see this happen: The test should pass.
Instead, this happened: The test fails when run with
RUSTFLAGS="-C target-cpu=icelake-client" cargo +nightly test -Zbuild-std --target x86_64-unknown-linux-gnu
. But it passes with, say,target-cpu=x86-64
, which points to this being a problem with the code generated for this specific cpu.In my analysis, the failure happens because
swizzle_dyn
ends up calling the_mm256_permutexvar_epi8
intrinsic with the arguments in reverse order. According to the docs, the first parameter is the index vector, but inswizzle_dyn
(via transize), the index vector is passed as the second argument. Oops!This analysis is corroborated by the fact that I can make it work by calling said intrinsic directly :)
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: