-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change #2633 was incomplete and it doesn't work in the context of generic functions. This PR fixes that.
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
//! Ensure we can use a generic function to access field of `repr_simd`. | ||
#![feature(portable_simd, repr_simd)] | ||
|
||
use std::simd::SimdElement; | ||
|
||
mod array_based { | ||
use super::*; | ||
|
||
#[repr(simd)] | ||
struct CustomSimd<T: SimdElement, const LANES: usize>([T; LANES]); | ||
|
||
fn check_fields<T: SimdElement + PartialEq, const LANES: usize>( | ||
simd: CustomSimd<T, LANES>, | ||
expected: [T; LANES], | ||
) { | ||
assert_eq!(simd.0, expected); | ||
} | ||
|
||
#[kani::proof] | ||
fn check_field_access() { | ||
let data: [u8; 16] = kani::any(); | ||
let vec = CustomSimd(data.clone()); | ||
check_fields(vec, data); | ||
} | ||
} | ||
|
||
mod fields_based { | ||
use super::*; | ||
|
||
#[repr(simd)] | ||
struct CustomSimd<T: SimdElement>(T, T); | ||
|
||
fn check_fields<T: SimdElement + PartialEq, const LANES: usize>( | ||
simd: CustomSimd<T>, | ||
expected: [T; LANES], | ||
) { | ||
assert_eq!(simd.0, expected[0]); | ||
assert_eq!(simd.1, expected[1]) | ||
} | ||
|
||
#[kani::proof] | ||
fn check_field_access() { | ||
let data: [u8; 16] = kani::any(); | ||
let vec = CustomSimd(data[0], data[1]); | ||
check_fields(vec, data); | ||
} | ||
} |