Skip to content

Commit 9528230

Browse files
committed
Change method Vector::loadu_si argument to accept a *const u8
It makes more sense to uniformly accept a `*const u8` here in order to be really clear about the unaligned-ness of the load.
1 parent d1053b6 commit 9528230

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/x86.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ trait Vector: Copy {
3333

3434
unsafe fn set1_epi8(a: i8) -> Self;
3535

36-
unsafe fn loadu_si(a: *const Self) -> Self;
36+
unsafe fn loadu_si(a: *const u8) -> Self;
3737

3838
unsafe fn cmpeq_epi8(a: Self, b: Self) -> Self;
3939

@@ -58,7 +58,7 @@ impl Vector for __m16i {
5858

5959
#[inline]
6060
#[target_feature(enable = "avx2")]
61-
unsafe fn loadu_si(a: *const Self) -> Self {
61+
unsafe fn loadu_si(a: *const u8) -> Self {
6262
__m16i(_mm_set1_epi16(std::ptr::read_unaligned(a as *const i16)))
6363
}
6464

@@ -97,7 +97,7 @@ impl Vector for __m32i {
9797

9898
#[inline]
9999
#[target_feature(enable = "avx2")]
100-
unsafe fn loadu_si(a: *const Self) -> Self {
100+
unsafe fn loadu_si(a: *const u8) -> Self {
101101
__m32i(_mm_set1_epi32(std::ptr::read_unaligned(a as *const i32)))
102102
}
103103

@@ -136,7 +136,7 @@ impl Vector for __m64i {
136136

137137
#[inline]
138138
#[target_feature(enable = "avx2")]
139-
unsafe fn loadu_si(a: *const Self) -> Self {
139+
unsafe fn loadu_si(a: *const u8) -> Self {
140140
__m64i(_mm_set_epi64x(0, std::ptr::read_unaligned(a as *const i64)))
141141
}
142142

@@ -170,8 +170,8 @@ impl Vector for __m128i {
170170

171171
#[inline]
172172
#[target_feature(enable = "avx2")]
173-
unsafe fn loadu_si(a: *const Self) -> Self {
174-
_mm_loadu_si128(a)
173+
unsafe fn loadu_si(a: *const u8) -> Self {
174+
_mm_loadu_si128(a as *const Self)
175175
}
176176

177177
#[inline]
@@ -204,8 +204,8 @@ impl Vector for __m256i {
204204

205205
#[inline]
206206
#[target_feature(enable = "avx2")]
207-
unsafe fn loadu_si(a: *const Self) -> Self {
208-
_mm256_loadu_si256(a)
207+
unsafe fn loadu_si(a: *const u8) -> Self {
208+
_mm256_loadu_si256(a as *const Self)
209209
}
210210

211211
#[inline]
@@ -366,8 +366,8 @@ impl<N: Needle> Avx2Searcher<N> {
366366
start: *const u8,
367367
mask: i32,
368368
) -> bool {
369-
let first = Vector::loadu_si(start.cast());
370-
let last = Vector::loadu_si(start.add(self.position).cast());
369+
let first = Vector::loadu_si(start);
370+
let last = Vector::loadu_si(start.add(self.position));
371371

372372
let eq_first = Vector::cmpeq_epi8(hash.first, first);
373373
let eq_last = Vector::cmpeq_epi8(hash.last, last);

0 commit comments

Comments
 (0)