Open AndyAyersMS opened 2 years ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
FYI @dotnet/jit-contrib. Probably lots to add here...
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch See info in area-owners.md if you want to be subscribed.
Author: | AndyAyersMS |
---|---|
Assignees: | - |
Labels: | `area-CodeGen-coreclr`, `untriaged` |
Milestone: | - |
I'm not really sure why we run CSE before AP anyways.
The primary benefit of running assertion propagation after CSE is the ability to take advantage of the refined conservative VNs.
I'm not really sure why we run CSE before AP anyways.
The primary benefit of running assertion propagation after CSE is the ability to take advantage of the refined conservative VNs.
Ah. you'd think I would have remembered https://github.com/dotnet/runtime/issues/45658. At any rate we don't actually have to do the CSE up front, just know that it is possible. For instance, we could recognize CSE candidates but defer optimizing and then see which CSEs AP benefits from before we figure out which ones we should (or now, have to) do.
We already have GTF_MAKE_CSE
for the interaction of hoisting and CSE -- though somewhat oddly we don't look for this in our CSE profitability analysis. Seems like we should at least keep track of cases where hosting thinks we should CSE but CSE disagrees.
Tracking issue for work and ideas about Assertion Prop.
Recent work
Not a complete list -- will fill this out over time.
Existing open issues
Not a complete list -- will fill this out over time. Also need to go back through these to see how many are no longer relevant.
Ideas
Local Assertion Prop
Extend local prop to work cross-block. If a block's successor has no other predecessors, the successor can inherit the assertion state. This extends local prop to work across join-free regions.
I worked up a simple-minded prototype of this that just handles the case where the predecessor is BBJ_NONE and successor is join free. It revealed some annoying interaction with VN and CSE, in particular, if we have code like:
Then locally propping a non-null
this
intoBB02
breaks CSE, because the two big trees now have different exception sets (this may in fact happen already if the first tree is in BB01).Some possible remedies:
this
" VN. This idea of fake defs is powerful and could possibly be leveraged for many other things. But it might be too costly for us.Enhance Assertion Kill/Gen Logic
Currently in local prop, we kill assertions for unaliased locals. This includes killing promoted local asserts when a parent struct is assigned to, and killing parent struct asserts when a promoted field is assigned to. However, this is pessimistic in the common case where a field is assigned a value it already has, eg redundant zeroing of fields:
In general, we don't do "gen" for promoted structs and their fields with the same thoroughness that we do "kill" so there is an asymmetry here. Arguably a ZEROOBJ on a promoted struct should inspire zero assertions for all its fields. But we may be better off not generating these quasi-redundant assertions and instead teach the lookup logic to understand parent/child relationships.
I have a prototype for this but will wait for #74384 to finalize first.
Flow dependent prop for address-taken locals
In many cases we may be able to prove that address-takenness is not applicable to a span of local defs and uses, eg the last "use" is the one that causes exposure (say a struct passed by
ref
).category:planning theme:assertion-prop skill-level:expert cost:medium impact:medium