Replace opened Pack Element types with the concrete type of the element when it is statically known#88591
Draft
aidan-hall wants to merge 6 commits intoswiftlang:mainfrom
Draft
Replace opened Pack Element types with the concrete type of the element when it is statically known#88591aidan-hall wants to merge 6 commits intoswiftlang:mainfrom
aidan-hall wants to merge 6 commits intoswiftlang:mainfrom
Conversation
1971cbd to
5c396a0
Compare
Note that we have made GenericEnvironment::getOpenedPackParams public.
In some scenarios, it is possible to statically determine which element of a pack a pack indexing instruction will access.
LocalArchetype is the shared base class of ArchetypeType (which SimplifyApply previously worked with) and ElementArchetypeType (@pack_element() types). This allows us to specialize calls to generic functions inside "repeat ... each" expressions and loops within specialized variadic generic functions.
5c396a0 to
37cc040
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Explanation
When using a
@pack_elementtype to refer to an element of a concrete pack type at a compile-time-known index, we can replace the@pack_elementwith the concrete type of the element at that index.witness_methodallows us to replace the witness table lookup and call with a direct call to the witness function for the concrete type.applymakes it possible to specialize calls to generic functions inside loops over pack elements.This is intended to be a smaller version of the changes proposed in #85333, and has limitations on what it can handle (e.g. it can only get the concrete pack type for
open_pack_elementinstructions that open a single pack type). Nonetheless, it enables more effective optimisations in many cases.Scope
TODO
Issues
rdar://163046681 (at least partially)
Risk
TODO
Testing
TODO