-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SIL Optimization] Make ArraySemantics.cpp aware of "array.uninitialized_intrinsic" #29643
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
[SIL Optimization] Make ArraySemantics.cpp aware of "array.uninitialized_intrinsic" #29643
Conversation
@swift-ci Please test |
@swift-ci Please benchmark |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -OnoneCode size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci Please benchmark |
Performance: -O
Code size: -OPerformance: -OsizeCode size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
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!
I mentioned some cosmetic issues in my comments.
@@ -652,7 +671,20 @@ SILValue swift::ArraySemanticsCall::getArrayValue() const { | |||
} | |||
|
|||
SILValue swift::ArraySemanticsCall::getArrayElementStoragePointer() const { | |||
if (getKind() == ArrayCallKind::kArrayUninitialized) { |
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.
This function looks almost exactly the same as getArrayValue(), except the tuple element number (and the special handling of ArrayCallKind::kArrayInit in getArrayValue).
Can you extract the common code into a helper function? e.g. getArrayInitResult(int tupleElement)
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.
Sure. That is a good idea.
} else if (SI) | ||
return false; | ||
|
||
// Store an index_addr projection. |
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.
typo: Store to an ...
…zed_intrinsic" semantics attribute that is used by the top-level array initializer (in ArrayShared.swift), which is the entry point used by the compiler to initialize array from array literals. This initializer is early-inlined so that other optimizations can work on its body. Fix DeadObjectElimination and ArrayCOWOpts optimization passes to work with this semantics attribute in addition to "array.uninitialized", which they already use. Refactor mapInitializationStores function from ArrayElementValuePropagation.cpp to ArraySemantic.cpp so that the array-initialization pattern matching functionality implemented by the function can be reused by other optimizations.
72243bf
to
a6bed21
Compare
@swift-ci Please test and merge |
1 similar comment
@swift-ci Please test and merge |
@swift-ci Please test macOS Platform |
1 similar comment
@swift-ci Please test macOS Platform |
Build failed |
This semantics attribute is used by the top-level array initializer (in ArrayShared.swift),
which is the entry point used by the compiler to initialize array from array literals.
This initializer is "early inlined" so that other optimizations can work on its body.
This PR also updates DeadObjectElimination and ArrayCOWOpts optimization passes to work with this semantics attribute in addition to "array.uninitialized", which they already use. (But this will not make them more effective as they are also applied after early inlining.)
It also refactors
mapInitializationStores
function from ArrayElementValuePropagation.cpp toArraySemantic.cpp so that the array-initialization pattern matching functionality
implemented by the function can be reused by other optimizations.
The purpose of this PR is to reuse the functionality implemented in ArraySemantics such as
getArrayValue
,getStoragePointer
etc. in a new "mandatory" pass that will unroll forEach loops over array literals, which itself is aimed at optimizing the new os log calls (see #29651).