Skip to content

AVX2 related regression introduced by rust 1.56.0 and onwards #91839

Closed
@marmeladema

Description

@marmeladema

Code

I tried this code:

I expected to see this happen: tests pass with success
Instead, this happened: some tests are failing:

failures:
    tests::search_middle
    tests::search_multiple
    tests::search_prefix
    tests::search_suffix

Version it worked on

It most recently worked on: Rust 1.55.0

Version with regression

rustc +1.56.0 --version --verbose:

rustc 1.56.0 (09c42c458 2021-10-18)
binary: rustc
commit-hash: 09c42c45858d5f3aedfa670698275303a3d19afa
commit-date: 2021-10-18
host: x86_64-unknown-linux-gnu
release: 1.56.0
LLVM version: 13.0.0

and onwards (1.56.1, 1.57.0, beta and nightly)

How to reproduce

Just run the following command with the previously mentioned commit checked out:

$ cargo +1.56.0 test --release -- tests::search_middle

What does commit cloudflare/sliceslice-rs@a7d4556 do

It just moves method vector_search_in from the Avx2Searcher struct to the Searcher trait. Loosing the #[target_feature(enable = "avx2")] attribute at the same time.

I found two (unsatisfactory) way to make the tests pass:

    #[inline]
    // Uncommenting the following lines makes it work
    // #[target_feature(enable = "avx2")]
    unsafe fn vector_search_in<V: Vector>(

But that won't work ultimately because the trait is going to be implemented for other architectures.

        // Uncommenting the following lines makes it work
        // println!("[vector_search_in_chunk] hash.first={:?}", hash.first);
        println!("[vector_search_in_chunk] first={:?}", first);

Absolutely no idea why printing something would have any influence!

Everything works properly for rust versions <= 1.55.0

Bisection attempt

I have tried to use cargo-bisect-rustc to bisect and it seems introduced between nightly-2021-08-10 and nightly-2021-08-12 (there are no nightly for 2021-08-11).

Further (manual) bisection points to #87254 but I am not sure my bisection is actually correct so any help is welcome 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions