Skip to content

Regression on nightly in AVX2 byte shift intrinsics #85446

Closed
@marcgalois

Description

@marcgalois

Code

I tried this code:

use std::arch::x86_64::*;

fn main() {
    let input: [u8; 32] = [
        1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
        26, 27, 28, 29, 30, 31, 32,
    ];
    let output: [u8; 32] = unsafe {
        let input: __m256i = std::mem::transmute(input);
        let output = _mm256_bslli_epi128(input, 8);
        std::mem::transmute(output)
    };
    dbg!(output);
}

I expected to see this:

[src/main.rs:13] output = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 17, 18, 19, 20, 21, 22, 23, 24]

(which matches clang on the equivalent C++ code)

Instead, this happened:

[src/main.rs:13] output = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8]

Version it worked on

It most recently worked on: Stable rust 1.52.1

Version with regression

rustc --version --verbose:

rustc 1.54.0-nightly (fe72845f7 2021-05-16)
binary: rustc
commit-hash: fe72845f7bb6a77b9e671e6a4f32fe714962cec4
commit-date: 2021-05-16
host: x86_64-apple-darwin
release: 1.54.0-nightly
LLVM version: 12.0.1

I suspect that this issue was caused by rust-lang/stdarch#1067

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcI-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessICEBreaker-Cleanup-CrewHelping to "clean up" bugs with minimal examples and bisectionsO-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions