-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
JIT: IV widening does not kick in for a simple loop with array and string indexing #102068
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
We CSE the two zero extensions, but the heuristic then reasons that storing with a zero extension is free in the backend, so it doesn't give any profit to introducing the widened IV. It isn't able to reason that widening will allow the CSE'd local to be removed entirely.
With the extended analysis done in the strength reduction PR we should have enough context to replace all uses. With that PR we have
and could notice that derived IV [4] will all be replaceable by the new primary IV introduced when widening [0]. |
Another relevant example is private static int Foo(int[] arr, int start, int count)
{
int sum = 0;
for (int i = 0; i < count; i++)
{
sum += arr[start++];
}
return sum;
} where we similarly end up with a local due to the |
Not going to get to this in .NET 9. |
Example from @richlander:
Loop codegen:
Expected:
The text was updated successfully, but these errors were encountered: