JIT: Handle some "field offset computation" patterns#81998
JIT: Handle some "field offset computation" patterns#81998jakobbotsch merged 10 commits intodotnet:mainfrom
Conversation
Both during import and during VN. Just want to see TP impact, not sure if this is worth it.
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue DetailsBoth during import and during VN. Just want to see TP impact, not sure if this is worth it.
|
|
Would this help in situation like #9791? NativeAOT generates similar code in support of ValueType.Equals/GetHashCode. The code RyuJIT currently generates for it is not particularly compact: |
Yes, this should handle those kinds of patterns. |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
|
Reopening this given the additional motivation of #84095 |
src/coreclr/jit/lclmorph.cpp
Outdated
| // TODO-Correctness: Due to inlining we may end up with incorrectly typed SUB trees here. | ||
| assert(node->TypeIs(TYP_I_IMPL, TYP_BYREF)); |
|
Diffs. This is primarily for NAOT so doesn't really reflect in the diffs. BasicMinimalApi has 1111 injected TP cost is really from the local morph changes: Base: 99417650982, Diff: 99454354685, +0.0369%
?PostOrderVisit@LocalAddressVisitor@@QEAA?AW4fgWalkResult@Compiler@@PEAPEAUGenTree@@PEAU4@@Z : 31130610 : +6.61% : 73.44% : +0.0313%
?EvalUsingMathIdentity@ValueNumStore@@AEAAIW4var_types@@W4VNFunc@@II@Z : 6168480 : +6.05% : 14.55% : +0.0062%
`ValueNumStore::EvalUsingMathIdentity'::`2'::<lambda_2>::operator() : 860150 : NA : 2.03% : +0.0009%
?fgPerBlockLocalVarLiveness@Compiler@@QEAAXXZ : 174224 : +0.04% : 0.41% : +0.0002%
?fgMorphSmpOp@Compiler@@AEAAPEAUGenTree@@PEAU2@PEAUMorphAddrContext@1@PEA_N@Z : 141174 : +0.01% : 0.33% : +0.0001%
?gtSetEvalOrder@Compiler@@QEAAIPEAUGenTree@@@Z : 115047 : +0.01% : 0.27% : +0.0001%
GenTreeVisitor<`Compiler::optCSE_GetMaskData'::`2'::MaskDataWalker>::WalkTree : 59296 : +0.14% : 0.14% : +0.0001%
GenTreeVisitor<`Compiler::fgSetTreeSeq'::`2'::SetTreeSeqVisitor>::WalkTree : 57562 : +0.01% : 0.14% : +0.0001%
?fgMorphTree@Compiler@@QEAAPEAUGenTree@@PEAU2@PEAUMorphAddrContext@1@@Z : 51860 : +0.01% : 0.12% : +0.0001%
memset : -2570677 : -0.34% : 6.06% : -0.0026%Haven't really checked more in detail. cc @dotnet/jit-contrib PTAL @EgorBo |
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Both during local morph and during VN.
Fix #40021
Saves 3 KB on BasicMinimalApi after #84095 (there's 1111
__GetFieldHelperfunctions). About 0.04%. There's still a null check kept for each offset computation, which we cannot really get rid of, but NAOT could maybe emit the IL such that there is a dominating null check so that only one is emitted.Example:
Base:
Diff:
Local morph changes handle the pattern for local structs -- VN changes handle the pattern for classes (and more complicated struct cases, like storing them in locals, which there are a few examples of in #40021).