JIT: consistently mark method table accesses as invariant#45854
JIT: consistently mark method table accesses as invariant#45854AndyAyersMS merged 2 commits intodotnet:masterfrom
Conversation
Introduce a new utility method to create the IR for method table access, marking the resulting indir as invariant. This allows method table access CSEs (which will be increasingly common with the advent of PGO-enabled Guarded Devirtualization). Add a workaround to assertion prop for method table to be able to see through a CSE'd method table access. Remove optimizer inhibitions related to colon cond, as there are no qmark nodes around by this point.
|
@briansull PTAL Relatively modest impact. Most regressions are extra CSEs. A couple of them are missed knock-on bounds checks caused by extra CSEs (see #45658). Large wins are in methods that have big chains of type tests guarding casts... |
| { | ||
| tree->ClearAssertion(); | ||
|
|
||
| if (tree->gtFlags & GTF_COLON_COND) |
There was a problem hiding this comment.
Is GTF_COLON_COND dead code that is being removed with this change?
Maybe change it to an assert here.
I don't believe that we can create an assertion that is predicated on a conditional
There was a problem hiding this comment.
We remove QMARKS in morph, so perhaps this is too aggressive. I'll restore the bail out but only do it for local assertion prop.
| // original tree, of not. | ||
| // | ||
| inline GenTree* GenTree::gtUnwrapCSE() | ||
| { |
There was a problem hiding this comment.
While this is the format that we use for a CSE def there are several other places we will generate GT_COMMA's with this patterm.
Looking through the code base this function also is commonly used to generate an assignment to a new temp LclVar
GenTree* Compiler::fgInsertCommaFormTemp(GenTree** ppTree, CORINFO_CLASS_HANDLE structType /*= nullptr*/)
There was a problem hiding this comment.
It doesn't have to be a CSE, it could be any value. I can rename the helper.
During global prop we have a mixture of rules that key off VNs and also look at IR shapes. In general we should just be able to use the VNs to figure most things out, but that doesn't happen consistently today. So in this case I need to find the original IR shape.
|
@dotnet/jit-contrib ping |
BruceForstall
left a comment
There was a problem hiding this comment.
You removed some GTF_EXCEPT bits; I presume you've proved those are unnecessary, despite the comments there saying "null pointer exception"?
The new helper goes through |
Introduce a new utility method to create the IR for method table access,
marking the resulting indir as invariant. This allows method table access
CSEs (which will be increasingly common with the advent of PGO-enabled
Guarded Devirtualization).
Add a workaround to assertion prop for method table to be able to see
through a CSE'd method table access.
Remove optimizer inhibitions related to colon cond, as there are no qmark
nodes around by this point.