Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Unroll more Equals/StartsWith/EndsWith on arm64 #109036

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9573,6 +9573,7 @@ class Compiler
Memset,
Memcpy,
Memmove,
MemcmpU16,
ProfiledMemmove,
ProfiledMemcmp
};
Expand Down Expand Up @@ -9649,6 +9650,14 @@ class Compiler
threshold = maxRegSize * 4;
}

if (type == UnrollKind::MemcmpU16)
{
threshold = maxRegSize * 2;
#ifdef TARGET_ARM64
threshold = maxRegSize * 6;
#endif
}

// For profiled memcmp/memmove we don't want to unroll too much as it's just a guess,
// and it works better for small sizes.
if ((type == UnrollKind::ProfiledMemcmp) || (type == UnrollKind::ProfiledMemmove))
Expand Down
10 changes: 4 additions & 6 deletions src/coreclr/jit/importervectorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#pragma hdrstop
#endif

// For now the max possible size is Vector512<ushort>.Count * 2
#define MaxPossibleUnrollSize 64
// Overestimated threshold to avoid memory allocations,
#define MaxPossibleUnrollSize 128

//------------------------------------------------------------------------
// importer_vectorization.cpp
Expand Down Expand Up @@ -484,9 +484,8 @@ GenTree* Compiler::impUtf16StringComparison(StringComparisonKind kind, CORINFO_S
// We were unable to get the literal (e.g. dynamic context)
return nullptr;
}
if (cnsLength > (int)genTypeSize(roundDownMaxType(MaxPossibleUnrollSize * 2)))
if (cnsLength > ((int)getUnrollThreshold(MemcmpU16) / 2))
{
// Not more than two loads (of max width)
JITDUMP("UTF16 data is too long to unroll - bail out.\n");
return nullptr;
}
Expand Down Expand Up @@ -642,9 +641,8 @@ GenTree* Compiler::impUtf16SpanComparison(StringComparisonKind kind, CORINFO_SIG
// We were unable to get the literal (e.g. dynamic context)
return nullptr;
}
if (cnsLength > (int)genTypeSize(roundDownMaxType(MaxPossibleUnrollSize * 2)))
if (cnsLength > ((int)getUnrollThreshold(MemcmpU16) / 2))
{
// Not more than two loads (of max width)
JITDUMP("UTF16 data is too long to unroll - bail out.\n");
return nullptr;
}
Expand Down
Loading