-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Intrinsify Encoding.UTF8.GetByteCount for constant UTF-16 input #102246
Comments
Tagging subscribers to this area: @dotnet/area-system-text-encoding |
Correct area probably CodeGen-coreclr 😆 |
For constant UTF-8 strings, is |
The runtime/src/coreclr/jit/helperexpansion.cpp Lines 1616 to 1617 in 426edd0
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
I think it should be fairly trivial to intrinsify |
I have been recently staring at a lot of UTF-8 <-> UTF-16 manipulation code (in Garnet and ILCompiler name mangling 😆) and thought that if
UTF8EncodingSealed.ReadUTF8
is getting VN expansion when JIT can see the input is CNS, maybe it could be done forEncoding.UTF8.GetByteCount
too, which is most commonly used to calculate the buffer for the following(Try)GetBytes
call (or if the input fits to the existing buffer).We of course have
GetMaxByteCount
for the fast calculation of upper-bound, but doing thestr.Length * 3
makes the buffer lengths go over any stackalloc thresholds very quickly.This is very much inspired after and in theme with #85328 (and then painfully hitting #93501 😢 )
The text was updated successfully, but these errors were encountered: