Replies: 1 comment
-
/cc: @EgorBo |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When looking at the generated ASM for
M1
,s
is null checked a single time, but itsLength
is checked before each comparison with the constant strings.As all the constant strings are of length 4, we can make a single length check on
s
.Doing this generates ASM where we only have a single null check and a single length check.
It is possible for the JIT to perform a similar reasoning?
// * Summary *
BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.4291/22H2/2022Update)
Intel Core i7-10750H CPU 2.60GHz, 1 CPU, 12 logical and 6 physical cores
.NET SDK 9.0.100-preview.3.24204.13
[Host] : .NET 9.0.0 (9.0.24.17209), X64 RyuJIT AVX2
DefaultJob : .NET 9.0.0 (9.0.24.17209), X64 RyuJIT AVX2
And similarly when doing unrolled case-insensitive string comparisons
M3
has 6or
, whileM4
has a single.Beta Was this translation helpful? Give feedback.
All reactions