JIT: Disallow separate CSE candidates for struct GT_COMMA
s
#106387
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CSE normally creates candidates based on the normal VN of trees.
However, there is an exception for
GT_COMMA
nodes, where theGT_COMMA
itself creates a candidate with its op1 exceptions, while theop2 then creates the usual "normal VN" candidate.
This can be problematic for
TYP_STRUCT
typed trees. In the JIT we donot have a first class representation for
TYP_STRUCT
temporaries,meaning that these always are restricted in what their immediate user
is.
gtNewTempStore
thus needs special logic to keep this invariantsatisfied; one of those special cases is that for
GT_COMMA
, instead ofcreating the store with the comma as the source, we sink the store into
the
op2
recursively so that we end up with the store immediately nextto the node that produces the struct value. This is ok since we are
storing to a new local anyway, so there can't be interference with the
op1's of the commas we skipped into.
This, however, causes problems for CSE with the
GT_COMMA
special caseabove. If we end up CSE'ing the outer comma we will create a definition
that is sunk into
op2
of the comma. If thatop2
is itself asCOMMA
that was a CSE candidate, then once we get to that candidate it no
longer has an IR shape that produces a value, and we thus cannot create
a CSE definition. The fix is to avoid creating separate CSE candidates
for struct-typed commas.
Fix #106380
#91586 is a better long term solution. I think to make that happen we should allow struct temporaries in HIR/LIR and have lowering figure out how to insert proper locals when it sees interference for struct LIR edges. That should be much better since there are many
varTypeIsStruct(x)
trees that actually do have first class handling in the backend, for example multi-reg and SIMD nodes.