Skip to content

Bug in test_mm_srav_epi64 from Rust repo #2232

Description

@antoyo

Hi.
There were changes in the Rust repo for the test_mm_srav_epi64 and it seems there's a bug in the test since it fails.
Here's a reproducer:

#![feature(portable_simd)]

use std::arch::x86_64::{__m128i, _mm_set_epi64x, _mm_set1_epi64x, _mm_srav_epi64};
use std::mem::transmute;
use std::simd::u32x4;

#[track_caller]
pub(crate) fn assert_eq_m128i(a: __m128i, b: __m128i) {
    unsafe {
        assert_eq!(transmute::<__m128i, u32x4>(a), transmute::<__m128i, u32x4>(b));
    }
}

#[target_feature(enable = "avx512f,avx512vl")]
fn test_mm_srav_epi64() {
    let a = _mm_set_epi64x(1 << 5, 0);
    let count = _mm_set1_epi64x(1);
    let r = _mm_srav_epi64(a, count);
    let e = _mm_set_epi64x(1 << 4, 0);
    assert_eq_m128i(r, e);

    let a = _mm_set_epi64x(-1, -2);
    let b = _mm_set_epi64x(64, 65);
    let r = _mm_srav_epi64(a, b);
    let e = _mm_set_epi64x((-1i64).unbounded_shl(64), (-2i64).unbounded_shl(65));
    assert_eq_m128i(r, e);
    let e = _mm_set_epi64x(-1, -1);
    assert_eq_m128i(r, e);
}

fn main() {
    unsafe { test_mm_srav_epi64(); }
}

This gives the following failure:

thread 'main' (507670) panicked at src/main.rs:26:5:
assertion `left == right` failed
  left: [4294967295, 4294967295, 4294967295, 4294967295]
 right: [0, 0, 0, 0]
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

(As a side note, is it expected to change stdarch or its tests from the Rust repo since I think no stdarch tests are ran there?)
Thanks to fix this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions