You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fold primitive-typed access to promoted structs in local morph and forbid mismatched struct assignments (#76766)
* GenTree::GetLayout field FIELDs
* Do not create invalid IR when replacing promoted fields
Instead, create constructions like "OBJ(ADDR(LCL_VAR))"
that block morphing can recognize on its own.
* Delete lvFieldHnd
* GenTree::GetLayout - CALL/COMMA
* GenTreeHWIntrinsic::GetLayout
* Add an assert that LHS and RHS match
* Fix assert violation
And simplify the code...
* Delete RetypedAsScalarFieldsMap
Without handle equality, the assert no longer holds, for example:
```cs
private StructWithInt Problem(StructWithInt b, StructWithInt a)
{
a = ((StructWithStructWithInt*)&b)->StructWithInt;
return a;
}
```
* Delete a bit of code
Dead / unncessary.
No diffs.
* Fold promoted locals in local morph
* Support GT_IND in MorphStructField
This is significantly simpler than moving the promotion logic
to post-order because we don't need to fiddle with the ref
counting process and complexities of intermediate states, e. g.
"IND<float>(ADDR(FIELD<int>(ADDR(LCL_VAR<struct>))))" can be
naturally turned into "BITCAST<float>(LCL_VAR<int>)" like this.
* More code removal
* Move "fgMorphStructField" to local morph
* TP tuning
With this, we have only a very small regression:
Base: 1297463478, Diff: 1297750893, +0.0222%
LocalAddressVisitor::MorphStructField : 345099 : NA : 31.52% : +0.0266%
LocalAddressVisitor::PreOrderVisit : 224684 : +3.53% : 20.52% : +0.0173%
memset : 88591 : +0.99% : 8.09% : +0.0068%
Compiler::fgMorphSmpOp : -19170 : -0.06% : 1.75% : -0.0015%
Compiler::fgMorphStructField : -367474 : -100.00% : 33.56% : -0.0283%
(This is with a dummy field on LclVarDsc)
Losing the assert does not seem worrysome as we have an identical one in "fgMorphField".
0 commit comments