1
1
//! Private implementation details of public gather/scatter APIs.
2
+ #[ cfg( not( bootstrap) ) ]
3
+ use crate :: simd:: intrinsics;
2
4
use crate :: simd:: { LaneCount , Simd , SupportedLaneCount } ;
5
+ #[ cfg( bootstrap) ]
3
6
use core:: mem;
4
7
5
8
/// A vector of *const T.
@@ -21,12 +24,16 @@ where
21
24
#[ inline]
22
25
#[ must_use]
23
26
pub fn wrapping_add ( self , addend : Simd < usize , LANES > ) -> Self {
27
+ #[ cfg( bootstrap) ]
24
28
// Safety: converting pointers to usize and vice-versa is safe
25
29
// (even if using that pointer is not)
26
30
unsafe {
27
31
let x: Simd < usize , LANES > = mem:: transmute_copy ( & self ) ;
28
32
mem:: transmute_copy ( & { x + ( addend * Simd :: splat ( mem:: size_of :: < T > ( ) ) ) } )
29
33
}
34
+ #[ cfg( not( bootstrap) ) ]
35
+ // Safety: this intrinsic doesn't have a precondition
36
+ unsafe { intrinsics:: simd_arith_offset ( self , addend) }
30
37
}
31
38
}
32
39
@@ -49,11 +56,15 @@ where
49
56
#[ inline]
50
57
#[ must_use]
51
58
pub fn wrapping_add ( self , addend : Simd < usize , LANES > ) -> Self {
59
+ #[ cfg( bootstrap) ]
52
60
// Safety: converting pointers to usize and vice-versa is safe
53
61
// (even if using that pointer is not)
54
62
unsafe {
55
63
let x: Simd < usize , LANES > = mem:: transmute_copy ( & self ) ;
56
64
mem:: transmute_copy ( & { x + ( addend * Simd :: splat ( mem:: size_of :: < T > ( ) ) ) } )
57
65
}
66
+ #[ cfg( not( bootstrap) ) ]
67
+ // Safety: this intrinsic doesn't have a precondition
68
+ unsafe { intrinsics:: simd_arith_offset ( self , addend) }
58
69
}
59
70
}
0 commit comments