-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Jit: fix for broken type equality optimization #9562
Conversation
The jit relies on a particular tree remaining intact during importation to optimize type equality tests commonly found in generics. In dotnet#7909 the jit started aggressively spilling the evaluation stack before calls, which broke up the trees needed for the optimizations. In the special cases pertaining to type tests the trees can safely remain intact because we know the calls can't interact with the computations on the stack. Recognize these cases and selectively suppress spilling. Closes #9552.
@JosephTremoulet PTAL Fixes the case in #9552. Code size diffs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but worth considering whether to generalize the helper call case to check some subset of these flags
Thanks, @JosephTremoulet and @AndyAyersMS! I applied Joseph's change and looked at the case in AsyncTaskMethodBuilder I cared about.... significant drop in the amount of assembly, though there was still one CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE call remaining that looked unnecessary. Then I applied Andy's change as well, and it went away. Everything looks good to me now. Thanks! |
This isn't the only place in the importer that can spill so perhaps we can use special knowledge of the callee more generally to pare down the side effect flags for GT_CALL nodes and reduce interference in more cases. Will look at that separately. |
Probably in general dead-code elimination we're conservative about removing dead calls for fear of side-effects, and the optimization in morph is more aggressive. I wonder how many unnecessary helper calls get left around... |
Note that we don't value number blocks that are unreachable at all. Thus if this pattern occurs in an unreachable block we won't eliminate it via identical value numbers. This leads to a A/V in our new JIT in some customer code that contains a loop that is entirely unreachable,when we try to unpack value numbers to see if we can eliminate a null check. |
…quality Jit: fix for broken type equality optimization Commit migrated from dotnet/coreclr@965d079
The jit relies on a particular tree remaining intact during importation
to optimize type equality tests commonly found in generics.
In #7907 the jit started aggressively spilling the evaluation stack before
calls, which broke up the trees needed for the optimizations.
In the special cases pertaining to type tests the trees can safely remain
intact because we know the calls can't interact with the computations on
the stack. Recognize these cases and selectively suppress spilling.
Closes #9552.