-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Suboptimal codegen with StartsWith(literal)
#110019
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
This probably needs some form of late forward substitution. Perhaps we should look into removing single-def single-use locals during rationalization (I have some code lying around to do this...). |
The problem is that we end up with IR like
and later we are able to show that It might be that we can teach qmark expansion to do some jump threading directly for cases like this, avoiding the intermediate local. Essentially qmark expansion would need to realize that the if (SequenceEqual(a, b, 4) || SequenceEqual(a, b, len))
goto passed;
... It requires liveness, but we do have liveness available when qmark expansion runs. However making use of it might interfere with @AndyAyersMS's future plans to move qmark expansion backwards... |
Although the problem also happens with bool x;
if ("HTTP/1.1"u8.Length > line.Length)
x = false;
else
x = SequenceEqual(a, b, c);
if (x)
{
passed:
// do something
} RBO is able to prove that We either need some smarter jump threading here (changing the |
When switching from the
BitConverter.ToUInt64
hack to the more readableStartsWith(literal)
, the codegen slightly regresses (doesn't matter for actual perf in this case).https://www.diffchecker.com/X4PhzKVx/
Patterns like
The text was updated successfully, but these errors were encountered: