Skip to content

Commit 0f500f8

Browse files
workingjubileeAmanieu
authored andcommitted
Clarify undefined can still mean init
These intrinsics actually are zeroing, so we should be upfront that these still return a valid value in reality. At most, we might in the future want to use a "freezing" semantics here. In any case, they are definitely not returning MaybeUninit, or any other possibly-poison value.
1 parent d7a4803 commit 0f500f8

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

crates/core_arch/src/x86/avx.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,9 @@ pub unsafe fn _mm256_zextpd128_pd256(a: __m128d) -> __m256d {
26872687
simd_shuffle!(a, _mm_setzero_pd(), [0, 1, 2, 3])
26882688
}
26892689

2690-
/// Returns vector of type `__m256` with undefined elements.
2690+
/// Returns vector of type `__m256` with indeterminate elements.
2691+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
2692+
/// In practice, this is equivalent to [`mem::zeroed`].
26912693
///
26922694
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_undefined_ps)
26932695
#[inline]
@@ -2698,7 +2700,9 @@ pub unsafe fn _mm256_undefined_ps() -> __m256 {
26982700
_mm256_set1_ps(0.0)
26992701
}
27002702

2701-
/// Returns vector of type `__m256d` with undefined elements.
2703+
/// Returns vector of type `__m256d` with indeterminate elements.
2704+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
2705+
/// In practice, this is equivalent to [`mem::zeroed`].
27022706
///
27032707
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_undefined_pd)
27042708
#[inline]
@@ -2709,7 +2713,9 @@ pub unsafe fn _mm256_undefined_pd() -> __m256d {
27092713
_mm256_set1_pd(0.0)
27102714
}
27112715

2712-
/// Returns vector of type __m256i with undefined elements.
2716+
/// Returns vector of type __m256i with with indeterminate elements.
2717+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
2718+
/// In practice, this is equivalent to [`mem::zeroed`].
27132719
///
27142720
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm256_undefined_si256)
27152721
#[inline]

crates/core_arch/src/x86/avx512f.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -29616,7 +29616,9 @@ pub unsafe fn _mm512_mask_reduce_or_epi64(k: __mmask8, a: __m512i) -> i64 {
2961629616
))
2961729617
}
2961829618

29619-
/// Returns vector of type `__m512d` with undefined elements.
29619+
/// Returns vector of type `__m512d` with indeterminate elements.
29620+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
29621+
/// In practice, this is equivalent to [`mem::zeroed`].
2962029622
///
2962129623
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_undefined_pd)
2962229624
#[inline]
@@ -29626,7 +29628,9 @@ pub unsafe fn _mm512_undefined_pd() -> __m512d {
2962629628
_mm512_set1_pd(0.0)
2962729629
}
2962829630

29629-
/// Returns vector of type `__m512` with undefined elements.
29631+
/// Returns vector of type `__m512` with indeterminate elements.
29632+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
29633+
/// In practice, this is equivalent to [`mem::zeroed`].
2963029634
///
2963129635
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_undefined_ps)
2963229636
#[inline]
@@ -29636,7 +29640,9 @@ pub unsafe fn _mm512_undefined_ps() -> __m512 {
2963629640
_mm512_set1_ps(0.0)
2963729641
}
2963829642

29639-
/// Return vector of type __m512i with undefined elements.
29643+
/// Return vector of type __m512i with indeterminate elements.
29644+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
29645+
/// In practice, this is equivalent to [`mem::zeroed`].
2964029646
///
2964129647
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_undefined_epi32&expand=5995)
2964229648
#[inline]
@@ -29646,7 +29652,9 @@ pub unsafe fn _mm512_undefined_epi32() -> __m512i {
2964629652
_mm512_set1_epi32(0)
2964729653
}
2964829654

29649-
/// Return vector of type __m512 with undefined elements.
29655+
/// Return vector of type __m512 with indeterminate elements.
29656+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
29657+
/// In practice, this is equivalent to [`mem::zeroed`].
2965029658
///
2965129659
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm512_undefined&expand=5994)
2965229660
#[inline]

crates/core_arch/src/x86/sse.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,9 @@ pub unsafe fn _mm_prefetch<const STRATEGY: i32>(p: *const i8) {
17541754
prefetch(p, (STRATEGY >> 2) & 1, STRATEGY & 3, 1);
17551755
}
17561756

1757-
/// Returns vector of type __m128 with undefined elements.
1757+
/// Returns vector of type __m128 with indeterminate elements.
1758+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
1759+
/// In practice, this is equivalent to [`mem::zeroed`].
17581760
///
17591761
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_undefined_ps)
17601762
#[inline]

crates/core_arch/src/x86/sse2.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2737,7 +2737,9 @@ pub unsafe fn _mm_castsi128_ps(a: __m128i) -> __m128 {
27372737
transmute(a)
27382738
}
27392739

2740-
/// Returns vector of type __m128d with undefined elements.
2740+
/// Returns vector of type __m128d with indeterminate elements.
2741+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
2742+
/// In practice, this is equivalent to [`mem::zeroed`].
27412743
///
27422744
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_undefined_pd)
27432745
#[inline]
@@ -2747,7 +2749,9 @@ pub unsafe fn _mm_undefined_pd() -> __m128d {
27472749
__m128d(0.0, 0.0)
27482750
}
27492751

2750-
/// Returns vector of type __m128i with undefined elements.
2752+
/// Returns vector of type __m128i with indeterminate elements.
2753+
/// Despite being "undefined", this is some valid value and not equivalent to [`mem::MaybeUninit`].
2754+
/// In practice, this is equivalent to [`mem::zeroed`].
27512755
///
27522756
/// [Intel's documentation](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_undefined_si128)
27532757
#[inline]

0 commit comments

Comments
 (0)