dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.26k stars 4.73k forks source link

JIT: hoist loop invariant null checks (and other exception causing trees) if they happen before other side effects #86536

Open AndyAyersMS opened 1 year ago

AndyAyersMS commented 1 year ago

In https://github.com/dotnet/runtime/issues/74081#issuecomment-1555407459 we see a loop where the very first thing in the loop body is a loop-invariant null check. We should be able to hoist this and other similar exception-causing trees into the preheader provided the exceptions happen before any side effect.

ghost commented 1 year ago

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.

Issue Details
In https://github.com/dotnet/runtime/issues/74081#issuecomment-1555407459 we see a loop where the very first thing in the loop body is a loop-invariant null check. We should be able to hoist this and other similar exception-causing trees into the preheader provided the exceptions happen before any side effect.
Author: AndyAyersMS
Assignees: -
Labels: `area-CodeGen-coreclr`, `untriaged`
Milestone: -
AndyAyersMS commented 1 year ago

@BruceForstall FYI cc @dotnet/jit-contrib

jakobbotsch commented 1 year ago

In #74081 (comment) we see a loop where the very first thing in the loop body is a loop-invariant null check.

68588 was supposed to add support for this, we should check why it doesn't kick in.