@@ -834,10 +834,6 @@ pub fn select_unpredictable<T>(condition: bool, true_val: T, false_val: T) -> T
834
834
#[ non_exhaustive]
835
835
#[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash ) ]
836
836
pub enum Locality {
837
- /// Data is unlikely to be reused soon.
838
- ///
839
- /// Typically bypasses the caches so they are not polluted.
840
- NonTemporal = 0 ,
841
837
/// Data is expected to be reused eventually.
842
838
///
843
839
/// Typically prefetches into L3 cache (if the CPU supports it).
@@ -880,15 +876,28 @@ pub enum Locality {
880
876
#[ unstable( feature = "hint_prefetch" , issue = "146941" ) ]
881
877
pub const fn prefetch_read_data < T > ( ptr : * const T , locality : Locality ) {
882
878
match locality {
883
- Locality :: NonTemporal => {
884
- intrinsics:: prefetch_read_data :: < T , { Locality :: NonTemporal as i32 } > ( ptr)
885
- }
886
879
Locality :: L3 => intrinsics:: prefetch_read_data :: < T , { Locality :: L3 as i32 } > ( ptr) ,
887
880
Locality :: L2 => intrinsics:: prefetch_read_data :: < T , { Locality :: L2 as i32 } > ( ptr) ,
888
881
Locality :: L1 => intrinsics:: prefetch_read_data :: < T , { Locality :: L1 as i32 } > ( ptr) ,
889
882
}
890
883
}
891
884
885
+ /// Prefetch the cache line containing `ptr` for a single future read, but attempt to avoid
886
+ /// polluting the cache.
887
+ ///
888
+ /// A strategically placed prefetch can reduce cache miss latency if the data is accessed
889
+ /// soon after, but may also increase bandwidth usage or evict other cache lines.
890
+ ///
891
+ /// A prefetch is a *hint*, and may be ignored on certain targets or by the hardware.
892
+ ///
893
+ /// Passing a dangling or invalid pointer is permitted: the memory will not
894
+ /// actually be dereferenced, and no faults are raised.
895
+ #[ inline( always) ]
896
+ #[ unstable( feature = "hint_prefetch" , issue = "146941" ) ]
897
+ pub const fn prefetch_read_data_non_temporal < T > ( ptr : * const T ) {
898
+ intrinsics:: prefetch_read_data :: < T , 0 > ( ptr)
899
+ }
900
+
892
901
/// Prefetch the cache line containing `ptr` for a future write.
893
902
///
894
903
/// A strategically placed prefetch can reduce cache miss latency if the data is accessed
@@ -901,9 +910,6 @@ pub const fn prefetch_read_data<T>(ptr: *const T, locality: Locality) {
901
910
#[ unstable( feature = "hint_prefetch" , issue = "146941" ) ]
902
911
pub const fn prefetch_write_data < T > ( ptr : * mut T , locality : Locality ) {
903
912
match locality {
904
- Locality :: NonTemporal => {
905
- intrinsics:: prefetch_write_data :: < T , { Locality :: NonTemporal as i32 } > ( ptr)
906
- }
907
913
Locality :: L3 => intrinsics:: prefetch_write_data :: < T , { Locality :: L3 as i32 } > ( ptr) ,
908
914
Locality :: L2 => intrinsics:: prefetch_write_data :: < T , { Locality :: L2 as i32 } > ( ptr) ,
909
915
Locality :: L1 => intrinsics:: prefetch_write_data :: < T , { Locality :: L1 as i32 } > ( ptr) ,
@@ -922,9 +928,6 @@ pub const fn prefetch_write_data<T>(ptr: *mut T, locality: Locality) {
922
928
#[ unstable( feature = "hint_prefetch" , issue = "146941" ) ]
923
929
pub const fn prefetch_read_instruction < T > ( ptr : * const T , locality : Locality ) {
924
930
match locality {
925
- Locality :: NonTemporal => {
926
- intrinsics:: prefetch_read_instruction :: < T , { Locality :: NonTemporal as i32 } > ( ptr)
927
- }
928
931
Locality :: L3 => intrinsics:: prefetch_read_instruction :: < T , { Locality :: L3 as i32 } > ( ptr) ,
929
932
Locality :: L2 => intrinsics:: prefetch_read_instruction :: < T , { Locality :: L2 as i32 } > ( ptr) ,
930
933
Locality :: L1 => intrinsics:: prefetch_read_instruction :: < T , { Locality :: L1 as i32 } > ( ptr) ,
0 commit comments