[llvm] [llvm] Improve implementation of StringRef::find_last_of and cie (PR #71865)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 15 14:53:50 PST 2023
================
@@ -268,17 +272,44 @@ StringRef::size_type StringRef::find_first_not_of(StringRef Chars,
return npos;
}
+#ifdef __SSE2__
+
+StringRef::size_type vectorized_find_last_of_specialized(const char *Data,
+ size_t Sz, char C0,
+ char C1) {
+ __m128i Needle0 = _mm_set1_epi8(C0);
+ __m128i Needle1 = _mm_set1_epi8(C1);
+ do {
+ Sz = Sz < 16 ? 0 : Sz - 16;
+ __m128i Buffer = _mm_loadu_si128((const __m128i *)(Data + Sz));
----------------
aganea wrote:
This load instruction will generate an out-of-bounds access if `strlen(Data)<15`. Do you think you can use the "slow" algorithm when that happens?
https://github.com/llvm/llvm-project/pull/71865
More information about the llvm-commits
mailing list