-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: optimize non-constant stackalloc to constant #97895
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
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsThis PR optimizes to because the latter is faster to zero (single instruction). Although, this consumes more stack so the threshold is low. Also, I need the generic
|
Does it slice it as well? Otherwise, that's a visible change that's almost guaranteed to break code that depended on span.Length being n rather than 64. |
Right, it doesn't change that behaviour, my example is not entirely correct from C# point of view, but it gives the idea of what JIT does for it under the hood. |
|
Also, this PR closes #81160 (although, I didn't plan it) |
|
What is the escape hatch for a user that truly wants to allocate as little stack as possible? In general I think we should be careful around changing stack consumption for patterns like this unless we have good evidence of benefits to motivate it (stack consumption vs execution speed is, as you say, a tradeoff)... |
This is just a draft to see the diffs. I wrote this function for a different opt, just noticed that it's a few lines of code to apply it for LCLHEAP. I don't have an answer on what threshold is safe to use to potentially increase stack usage for better perf. |
|
Closing since I am not feeling confident enough to increase stack consumption in such functions. |
This PR optimizes
to
because the latter is faster to zero (single instruction). Although, this consumes more stack, so the threshold is low.
Also, I need the generic
optAssertionProp_GetInt32Rangefunction in future opts I wanted to try.Example:
Codegen diff for
Test(): https://www.diffchecker.com/s6pIRCSa/