Skip to content

[release/7.0] Fix bug in String.Equals unrolling for CJK single-char strings #78234

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

Merged
merged 1 commit into from
Nov 14, 2022
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
2 changes: 1 addition & 1 deletion src/coreclr/jit/importer_vectorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ GenTree* Compiler::impExpandHalfConstEqualsSWAR(
// [ ch1 ]
// [value]
//
return impCreateCompareInd(data, TYP_SHORT, dataOffset, cns[0], cmpMode);
return impCreateCompareInd(data, TYP_USHORT, dataOffset, cns[0], cmpMode);
}
if (len == 2)
{
Expand Down
14 changes: 13 additions & 1 deletion src/tests/JIT/opt/Vectorization/StringEquals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static int Main()
}

Console.WriteLine(testCount);
return testCount == 25920 ? 100 : 0;
return testCount == 27888 ? 100 : 0;
}
}

Expand Down Expand Up @@ -195,10 +195,22 @@ static void ValidateEquals(bool result, string left, string right)
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_157(string s) => ValidateEquals(s == "2ж1311a23b2212aЙ21Й11жb3233bb3a1", s, "2ж1311a23b2212aЙ21Й11жb3233bb3a1");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_158(string s) => ValidateEquals(s == "01Й11113ь3Й32a3ьЙЙ3Й32b2ab221310", s, "01Й11113ь3Й32a3ьЙЙ3Й32b2ab221310");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_159(string s) => ValidateEquals(s == "a120213b11211\0223223312ьь1Й3222Й", s, "a120213b11211\0223223312ьь1Й3222Й");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_160(string s) => ValidateEquals(s == "\u9244", s, "\u9244");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_161(string s) => ValidateEquals(s == "\u9244\u9244", s, "\u9244\u9244");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_162(string s) => ValidateEquals(s == "\u9244\u9244\u9244", s, "\u9244\u9244\u9244");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_163(string s) => ValidateEquals(s == "\uFFFF", s, "\uFFFF");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_164(string s) => ValidateEquals(s == "\uFFFF\uFFFF", s, "\uFFFF\uFFFF");
[MethodImpl(MethodImplOptions.NoInlining)] public static void Equals_165(string s) => ValidateEquals(s == "\uFFFF\uFFFF\uFFFF", s, "\uFFFF\uFFFF\uFFFF");

public static readonly string[] s_TestData =
{
null,
"\u9244",
"\u9244\u9244",
"\u9244\u9244\u9244",
"\uFFFF",
"\uFFFF\uFFFF",
"\uFFFF\uFFFF\uFFFF",
"",
"\0",
"a",
Expand Down
8 changes: 7 additions & 1 deletion src/tests/JIT/opt/Vectorization/UnrollEqualsStartsWIth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static int Main()
int testCount = 0;
foreach (var testType in testTypes)
testCount += RunTests(testType);
return testCount == 113652 ? 100 : 0;
return testCount == 127512 ? 100 : 0;
}

public static int RunTests(Type type)
Expand All @@ -37,6 +37,12 @@ public static int RunTests(Type type)

string[] testData =
{
"\u9244",
"\u9244\u9244",
"\u9244\u9244\u9244",
"\uFFFF",
"\uFFFF\uFFFF",
"\uFFFF\uFFFF\uFFFF",
"",
string.Empty,
"a",
Expand Down