-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Optimizer: Improve performance of large InlineArrays at Onone #81706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimizer: Improve performance of large InlineArrays at Onone #81706
Conversation
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but there should be a comment at the top of SimplifyMarkDependence that it cannot run before dependency diagnostics. Dependencies on trivial values are meaningful for diagnostics.
* Move the mutating APIs into Context.swift, because SIL can only be mutated through a MutatingContext * move the `baseOperand` and `base` properties from the instruction classes to the `MarkDependenceInstruction` protocol * add `valueOrAddressOperand` and `valueOrAddress` in the `MarkDependenceInstruction` protocol
* re-implement the SILCombine peephole as a Swift instruction simplification * run this simplification also in the OnoneSimplification pass
This is a workaround for a bug in the move-only checker: rdar://151841926. The move-only checker sometimes inserts destroy_addr within read-only static access scopes. Therefore don't consider static access scopes as immutable scopes.
Introduce a new pass MandatoryTempRValueElimination, which works as the original TempRValueElimination, except that it does not remove any alloc_stack instruction which are associated with source variables. Running this pass at Onone helps to reduce copies of large structs, e.g. InlineArrays or structs containing InlineArrays. Copying large structs can be a performance problem, even at Onone. rdar://151629149
efc01b8
to
198d4ab
Compare
@swift-ci test |
@swift-ci apple silicon benchmark |
@swift-ci clean apple silicon benchmark |
@swift-ci benchmark |
@swift-ci apple silicon benchmark |
@swift-ci test macos |
We need to avoid copying large InlineArrays at Onone, because even for Onone the performance suffers too much if such copies are not eliminated.
The solution to this to run the TempRValueElimination at Onone.
In this PR I added a new MandatoryTempRValueElimination pass, which works as the original TempRValueElimination, except that it does not remove any alloc_stack instruction which are associated with source variables.
In addition it's required to simplify
mark_dependence
instructions at Onone. I re-implement the SILCombine peephole as a Swift instruction simplification and let run this simplification also in the OnoneSimplification pass.rdar://151629149