Skip to content
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

SILCombine: Handle result conversions for apply (convert_function) peephole #58713

Merged
merged 2 commits into from May 10, 2022

Conversation

jckarter
Copy link
Member

@jckarter jckarter commented May 6, 2022

If a convert_function instruction operates on a function with indirect
results, or changes the type of direct results, then we can transform
an application of the converted function into an application of the
original function followed by bitwise conversions of the results, just
like we have done for arguments. Now that closures are emitted at their
context abstraction level, they are more likely to be emitted with
indirect results, so the inability to simplify function conversions
in this case would lead to missed inlining opportunities we used to
take.

@jckarter
Copy link
Author

@jckarter jckarter commented May 6, 2022

@swift-ci Please benchmark

…ephole

If a `convert_function` instruction operates on a function with indirect
results, or changes the type of direct results, then we can transform
an application of the converted function into an application of the
original function followed by bitwise conversions of the results, just
like we have done for arguments. Now that closures are emitted at their
context abstraction level, they are more likely to be emitted with
indirect results, so the inability to simplify function conversions
in this case would lead to missed inlining opportunities we used to
take.
@drexin
Copy link

@drexin drexin commented May 7, 2022

@swift-ci benchmark

@drexin
Copy link

@drexin drexin commented May 7, 2022

Performance (x86_64): -O

Improvement OLD NEW DELTA RATIO
FlattenListFlatMap 2796 2583 -7.6% 1.08x (?)
DictionaryKeysContainsCocoa 15 14 -6.7% 1.07x (?)
DictionaryKeysContainsNative 15 14 -6.7% 1.07x (?)

Code size: -O

Performance (x86_64): -Osize

Improvement OLD NEW DELTA RATIO
DropFirstArray 14 13 -7.1% 1.08x (?)
Dict.FilterAllMatch.28k 1176 1097 -6.7% 1.07x (?)
FlattenListFlatMap 3670 3426 -6.6% 1.07x (?)

Code size: -Osize

Performance (x86_64): -Onone

Improvement OLD NEW DELTA RATIO
ObjectiveCBridgeStubDateAccess 3598 3301 -8.3% 1.09x (?)

Code size: -swiftlibs

instead of bitcasting the original type. Once the original tuple value is
rewritten, the projected element will be the type we want, so the
original instruction would be invalid anyway, and we can make
a new instruction with the correct type directly.
@jckarter jckarter force-pushed the sil-combiner-apply-result-conversions branch from 601486d to 2a668b9 Compare May 7, 2022
@jckarter jckarter marked this pull request as ready for review May 7, 2022
@jckarter jckarter changed the title WIP implement result conversions for apply (convert_function) peephole SILCombine: Handle result conversions for apply (convert_function) peephole May 7, 2022
@jckarter
Copy link
Author

@jckarter jckarter commented May 7, 2022

@swift-ci Please test

@jckarter
Copy link
Author

@jckarter jckarter commented May 7, 2022

@swift-ci Please test source compatibility

@jckarter
Copy link
Author

@jckarter jckarter commented May 9, 2022

@swift-ci Please test

@jckarter
Copy link
Author

@jckarter jckarter commented May 10, 2022

@swift-ci Please test source compatibility

@jckarter jckarter merged commit 47201cb into apple:main May 10, 2022
7 checks passed
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.

None yet

2 participants