Skip to content

Commit 5c1f598

Browse files
authored
Merge pull request #1945 from folkertdev/gfni-cleanup
use `byte_add` in gfni tests
2 parents 8b51bf5 + b4fbad5 commit 5c1f598

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

crates/core_arch/src/x86/gfni.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -881,26 +881,20 @@ mod tests {
881881
}
882882

883883
#[target_feature(enable = "sse2")]
884-
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
885884
unsafe fn load_m128i_word<T>(data: &[T], word_index: usize) -> __m128i {
886-
let byte_offset = word_index * 16 / size_of::<T>();
887-
let pointer = data.as_ptr().add(byte_offset) as *const __m128i;
885+
let pointer = data.as_ptr().byte_add(word_index * 16) as *const __m128i;
888886
_mm_loadu_si128(black_box(pointer))
889887
}
890888

891889
#[target_feature(enable = "avx")]
892-
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
893890
unsafe fn load_m256i_word<T>(data: &[T], word_index: usize) -> __m256i {
894-
let byte_offset = word_index * 32 / size_of::<T>();
895-
let pointer = data.as_ptr().add(byte_offset) as *const __m256i;
891+
let pointer = data.as_ptr().byte_add(word_index * 32) as *const __m256i;
896892
_mm256_loadu_si256(black_box(pointer))
897893
}
898894

899895
#[target_feature(enable = "avx512f")]
900-
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
901896
unsafe fn load_m512i_word<T>(data: &[T], word_index: usize) -> __m512i {
902-
let byte_offset = word_index * 64 / size_of::<T>();
903-
let pointer = data.as_ptr().add(byte_offset) as *const _;
897+
let pointer = data.as_ptr().byte_add(word_index * 64) as *const __m512i;
904898
_mm512_loadu_si512(black_box(pointer))
905899
}
906900

0 commit comments

Comments
 (0)