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

Enable ArrayBoundsCheckElimination on OSSA #35380

Merged
merged 3 commits into from
Jan 20, 2021

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Jan 12, 2021

Minor refactoring in ArrayBoundsCheckElimination
Support hoisting/copying owned/guaranteed self in ArraySemantics
Support OSSA instructions load [copy], copy_value, destroy_value in ArrayBoundsCheckElimination

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta
Copy link
Contributor Author

@swift-ci benchmark

@meg-gupta
Copy link
Contributor Author

@swift-ci test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a768c700912a694e86f9586cdd95fe916cc6dd6f

@meg-gupta
Copy link
Contributor Author

@swift-ci test macOS Platform

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
FlattenListFlatMap 4703 5719 +21.6% 0.82x (?)
UTF8Decode_InitFromCustom_contiguous_ascii_as_ascii 374 407 +8.8% 0.92x (?)

Code size: -O

Performance: -Osize

Regression OLD NEW DELTA RATIO
String.data.LargeUnicode 98 110 +12.2% 0.89x (?)
 
Improvement OLD NEW DELTA RATIO
NSStringConversion.MutableCopy.UTF8 909 840 -7.6% 1.08x (?)

Code size: -Osize

Performance: -Onone

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 8-Core Intel Xeon E5
  Processor Speed: 3 GHz
  Number of Processors: 1
  Total Number of Cores: 8
  L2 Cache (per Core): 256 KB
  L3 Cache: 25 MB
  Memory: 64 GB

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about replaceAllUsesWithUndef but otherwise it looks good.

include/swift/SILOptimizer/Analysis/ArraySemantic.h Outdated Show resolved Hide resolved
lib/SILOptimizer/Analysis/ArraySemantic.cpp Outdated Show resolved Hide resolved
}
auto *Copy = cast<CopyValueInst>(ArrayStructValue);
auto Addr = cast<LoadInst>(Copy->getOperand())->getOperand();
Copy->replaceAllUsesWithUndef();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't understand how replaceAllUsesWithUndef works here. What about other uses of the array value? The call may take a guaranteed self, or may be in a different block from the copy, no?

Copy link
Contributor Author

@meg-gupta meg-gupta Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it. Thanks!

} else {
auto Self = getSelf();
assert(isa<CopyValueInst>(Self) || isa<LoadInst>(Self));
Self->replaceAllUsesWithUndef();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I'm not sure how replaceAllUsesWithUndef works in general. Is it assuming the call takes an owned self and is in the same blocks. Even then, what about other non-consuming uses of the array that aren't being rewritten?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out. I fixed this and added a test.

- Updated free functions as class methods and avoid passing redundant
  args
- Updated ReleaseSafeArrays to be a class member
@meg-gupta
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@meg-gupta meg-gupta merged commit 8d217f3 into swiftlang:main Jan 20, 2021
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.

3 participants