Skip to content

Commit eeeeef9

Browse files
committed
fixed UB in _mm256_undefined_p{d,s} and _mm_undefined_ps
1 parent abf64fb commit eeeeef9

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

crates/core_arch/src/x86/avx.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,8 +2956,7 @@ pub unsafe fn _mm256_zextpd128_pd256(a: __m128d) -> __m256d {
29562956
// This intrinsic has no corresponding instruction.
29572957
#[stable(feature = "simd_x86", since = "1.27.0")]
29582958
pub unsafe fn _mm256_undefined_ps() -> __m256 {
2959-
// FIXME: this function should return MaybeUninit<__m256>
2960-
mem::MaybeUninit::<__m256>::uninit().assume_init()
2959+
_mm256_set1_ps(0.0)
29612960
}
29622961

29632962
/// Returns vector of type `__m256d` with undefined elements.
@@ -2968,8 +2967,7 @@ pub unsafe fn _mm256_undefined_ps() -> __m256 {
29682967
// This intrinsic has no corresponding instruction.
29692968
#[stable(feature = "simd_x86", since = "1.27.0")]
29702969
pub unsafe fn _mm256_undefined_pd() -> __m256d {
2971-
// FIXME: this function should return MaybeUninit<__m256d>
2972-
mem::MaybeUninit::<__m256d>::uninit().assume_init()
2970+
_mm256_set1_pd(0.0)
29732971
}
29742972

29752973
/// Returns vector of type __m256i with undefined elements.

crates/core_arch/src/x86/sse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,8 +1865,7 @@ pub unsafe fn _mm_prefetch(p: *const i8, strategy: i32) {
18651865
#[target_feature(enable = "sse")]
18661866
#[stable(feature = "simd_x86", since = "1.27.0")]
18671867
pub unsafe fn _mm_undefined_ps() -> __m128 {
1868-
// FIXME: this function should return MaybeUninit<__m128>
1869-
mem::MaybeUninit::<__m128>::uninit().assume_init()
1868+
_mm_set1_ps(0.0)
18701869
}
18711870

18721871
/// Transpose the 4x4 matrix formed by 4 rows of __m128 in place.

0 commit comments

Comments
 (0)