-
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
RyuJIT: IsValueType and IsAssignableFrom optimizations aren't inlining friendly. #40381
Comments
This happens in For more complex nodes the typical gotchas are side effect ordering (and in particular exception ordering), and the possibility of widespread code duplication. I have a prototype branch InlineForwardSubSingleUseWithException that allows more complex trees to be substituted (to address #4207). Trees with exception effects but no global effects can be handled by evaluating them both at the call site and at the use point, with the hope that both will get optimized. My notes say "One issue is that we'll dup arbitrarily large trees, might need to focus more on profitability." Note early on in the jit we don't have a good notion of how much computation a tree represents. |
#1157 introduced a jit optimization to optimize
typeof(X).IsValueType
to true/false. However, it seems this optimization doesn't work with inlining (same forIsAssignableFrom
), e.g.:Codegen for
Test
(withFoo
inlined):Expected codegen:
the problem here is the fact that when we inline Foo we save
typeof(int)
into a temp variable (GT_LCL_VAR) and then importer is not able to optimizeget_IsValueType
because it expects input to betypeof(X)
(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE
) rather than an unknown local, here is the IR after inlining:if we could, instead of saving
typeof(x)
into a temp propogate it by value during inlining I believe we'd get:Other options: early CSE ? or when I import
get_IsValueType
and seeLCL_VAR
arg withlvSingleDef
flag - can I quickly get its assignment node?PS: the same issue prevents the new API Type.IsAssignableTo to be
typeof(X)
friendly since it usesIsAssignableFrom
under the hood./cc @dotnet/jit-contrib
category:cq
theme:inlining
skill-level:expert
cost:large
The text was updated successfully, but these errors were encountered: