Repository navigation
JIT: Add GT_STORE_LCL_VARS to define multiple scalar locals from a single source - #137358
jakobbotsch wants to merge 10 commits into
Conversation
…single source Introduce `GT_STORE_LCL_VARS` with record-backed destinations and integrate it with logical local definitions, liveness, SSA, value numbering, register allocation, and code generation. Use the node for physically promoted struct stores. Lower compatible call returns directly into destination locals, spilling other sources through a struct temporary. Add promotion and code generation tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5380c17-dca4-4a54-b4bb-16ad9560f1e9
|
Azure Pipelines: Successfully started running 7 pipeline(s). 8 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 871f033a-5ea0-415f-b66b-023b998f8e3d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 871f033a-5ea0-415f-b66b-023b998f8e3d
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 823d72b5-b0b5-4b68-8d11-c642eb4bd586
|
/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
AndyAyersMS
left a comment
There was a problem hiding this comment.
Looks good overall.
We should look carefully at uses of OperIsLocal* , eg Wasm probably should have some assert in its allocator that it will not see a GT_STORE_LCL_VARS. Note wasm does have multiple-value returns but we don't use them (yet).
Another place this comes up is LIR side effect analysis, seems like we should need some changes in sideeffects.cpp?
| { | ||
| def.RegNum = REG_NA; | ||
| } | ||
| if (i + 1 < store->gtCount) |
There was a problem hiding this comment.
This probably deserves a comment
There was a problem hiding this comment.
I moved existing comments on our model of multi-reg stores to the remarks of this function, and updated the source places to point to this place instead.
…squashed # Conflicts: # src/coreclr/jit/compiler.hpp
Add `ReplaceVisitor::GetCallRemainderScratch`, which hands out locals from a per-visitor pool instead of creating new temps for each multi-local store from a call. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 823d72b5-b0b5-4b68-8d11-c642eb4bd586
Physical promotion now describes stores of struct-returning calls to promoted locals purely from the struct layout: the destinations of `GT_STORE_LCL_VARS` are the replacements plus layout-based remainder chunks, in offset order, and the node takes ownership of the destination array via a new `gtNewStoreLclVarsNode` overload. Mapping destinations to return registers is left entirely to lowering, which falls back to a stack spill for unsupported mappings. `gtSetStoreLclVarsDestination` is removed. SIMD and (on 32-bit targets) `long` replacements are no longer excluded. `DecomposeLongs::DecomposeStoreLclVars` splits `long` destinations into their halves, using the promoted fields or pooled `INT` temps that are reassembled with `GT_LONG`. Add tests for `long`, SIMD and padded call results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 823d72b5-b0b5-4b68-8d11-c642eb4bd586
…ted locals Physical promotion now creates `GT_STORE_LCL_VARS` for every struct store into a promoted local whose source is not handled by field-by-field decomposition, instead of only for certain calls. This includes multi-reg HW intrinsics, Swift calls, tail call candidates and stores that only partially overlap a replacement. - For tail call candidates, preceding effects are placed in a statement before the store and remainder stores in statements after it, so that morph can still turn the call into a tail call. `fgMorphPotentialTailCall` accepts `GT_STORE_LCL_VARS` roots, and `AggregateInfoMap::Lookup` handles locals created after the map was built. - Partially overlapping replacements are written back if needed, their overlapping bytes are stored through the remainder, and they are marked for read back. - Add `GenTree::GetSourceRegisterOffset`, which also handles Swift lowered offsets, and use it together with `GetMultiRegCount`/`GetRegTypeByIndex` in lowering instead of building a new `ReturnTypeDesc`. Remove `ReturnTypeDesc::InitializeStructCallReturnType`. - Lowering defines destinations that no source register covers as zero, and spills sources that define no registers (for example a struct local introduced by CSE). - Only create the rejected tail call temp in `fgMorphCall` when the call is returned directly. Add a test for multi-reg HW intrinsic results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 823d72b5-b0b5-4b68-8d11-c642eb4bd586
…ocals Create the rejected tail call temp in `fgMorphCall` for all rejected multi-reg struct tail call candidates, except when the call is the direct source of a `GT_STORE_LCL_VAR` or `GT_STORE_LCL_VARS` statement root, which already has a destination local. Previously the temp was only created for calls directly returned by `GT_RETURN` or `GT_SWIFT_ERROR_RET`, which missed shapes with no return node. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 823d72b5-b0b5-4b68-8d11-c642eb4bd586
Introduce
GT_STORE_LCL_VARSwith record-backed destinations and integrate it with logical local definitions, liveness, SSA, value numbering, register allocation, and code generation.Use the node for physically promoted struct stores. Lower compatible call returns directly into destination locals, spilling other sources through a struct temporary. Add promotion and code generation tests.