Skip to content

Some OSSA related optimization improvements #78054

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

Merged
merged 10 commits into from
Dec 11, 2024

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Dec 9, 2024

Several (relatively) small optimization improvements to better deal with OSSA:

  • GlobalPropertyOpt: handle load_borrow and destroy_addr
  • COWArrayOpt: handle load_borrow
  • LoopRotate: handle copy_value and begin_borrow correctly
  • LoopRotate: don't rotate a loop if the new header is loop exiting as well
  • LICM: (limited) support for OSSA
  • SimplifyDestructure: canonicalize destructure_tuple and destructure_struct for trivial tuples/structs
  • simplify load_borrow
  • remove begin_borrow if the borrowed value is a thin_to_thick_function
  • run begin_borrow simplification in SILCombine

For details see the commit messages.

This is part of fixing benchmark regressions when enabling OSSA modules.
rdar://139773406

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@meg-gupta
Copy link
Contributor

meg-gupta commented Dec 9, 2024

Awesome! I left some minor comments but this LGTM!

…eline.

It triggers a false alarm when building SwiftDocC on linux
rdar://141270464
…well

This doesn't give any performance benefit.
The first step: allow hoisting instructions which only have trivial operands and results.
…truct for trivial tuples/structs

Replace destructure_tuple with tuple_extract instructions and destructure_struct with struct_extract instructions.
This canonicalization helps other optimizations to e.g. CSE tuple_extract/struct_extract.
* Remove dead `load_borrow` instructions (replaces the old peephole optimization in SILCombine)
* If the `load_borrow` is followed by a `copy_value`, combine both into a `load [copy]`
…n_to_thick_function`

`thin_to_thick_function` has "none" ownership and is compatible with guaranteed values.
Therefore the `begin_borrow` is not needed.
@eeckstein eeckstein force-pushed the ossa-opt-improvements branch from 72e63d7 to 3e35df0 Compare December 11, 2024 11:33
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit b748546 into swiftlang:main Dec 11, 2024
5 checks passed
@eeckstein eeckstein deleted the ossa-opt-improvements branch December 11, 2024 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants