forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 344
Dse mssa opt 2 #3613
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
Dse mssa opt 2 #3613
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cherry-picked from 1a2a7cc)
That's https://reviews.llvm.org/D90328 follow-up. This change eliminates writes to variables where the value that is being written is already stored in the variable. This achieves the goal by looping through all memory definitions in the current state and getting defining access from each of them. When there is defining access where the write instruction is identical to the original instruction it will remove this redundant write. For example: void f() { x = 1; if foo() { x = 1; g(); } else { h(); } } void g(); void h(); The second x=1 will be eliminated since it is rewriting 1 to x. This pass will produce this: void f() { x = 1; if foo() { g(); } else { h(); } } void g(); void h(); Differential Revision: https://reviews.llvm.org/D111727 (cherry-picked from f87e0c6)
This patch adds support to remove stores that write the same value as earlier memesets. It uses isOverwrite to check that a memset completely overwrites a later store. The candidate store must store the same bytewise value as the byte stored by the memset. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D112321 (cherry-picked from 274a9b0)
Add OR_None code to indicate that there is no overwrite. This has no any effect for current uses but will be used in one of the next patches building support for PHI translation. Reviewed By: fhahn Differential Revision: https://reviews.llvm.org/D105098 (cherry-picked from 47e2644)
This patch extends the code that walks memory defs upwards to find clobbering accesses to also try to optimize the clobbering defining access. We should be able to find set the optimized access of our starting def (KillingDef), if the following holds: 1. It is the first call of getDomMemoryDef for KillingDef (so Current == KillingDef->getDefiningAccess(). 2. No potentially aliasing defs are skipped. Then if a (partly) aliasing def is encountered, it can be used as optimized access for KillingDef. No further optimizations can be applied to KillingDef. I'd appreciate a careful look, as the existing documentation is not too clear on what is expected for optimized accesses. The motivation for this patch is to use the optimized accesses to cover more cases of redundant stores as follow-up to D111727. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D112313 (cherry-picked from 25dad10)
Using the optimized access enables additional optimizations in cases where the defining access is a non-aliasing store. Alternatively we could also walk upwards and skip non-aliasing defs here, but my experiments so far showed that this will noticeably increase compile-time for little extra gain compared to just using the optimized access. Improvements of dse.NumRedundantStores on MultiSource/CINT2006/CPF2006 on X86 with -O3: test-suite...-typeset/consumer-typeset.test 1.00 76.00 7500.0% test-suite.../Benchmarks/Bullet/bullet.test 3.00 12.00 300.0% test-suite...006/453.povray/453.povray.test 3.00 6.00 100.0% test-suite...telecomm-gsm/telecomm-gsm.test 1.00 2.00 100.0% test-suite...ediabench/gsm/toast/toast.test 1.00 2.00 100.0% test-suite...marks/7zip/7zip-benchmark.test 1.00 2.00 100.0% test-suite...ications/JM/lencod/lencod.test 7.00 10.00 42.9% test-suite...6/464.h264ref/464.h264ref.test 6.00 8.00 33.3% test-suite...ications/JM/ldecod/ldecod.test 6.00 7.00 16.7% test-suite...006/447.dealII/447.dealII.test 33.00 33.00 0.0% test-suite...6/471.omnetpp/471.omnetpp.test NaN 1.00 nan% test-suite...006/450.soplex/450.soplex.test NaN 2.00 nan% test-suite.../CINT2006/403.gcc/403.gcc.test NaN 7.00 nan% test-suite...lications/ClamAV/clamscan.test NaN 1.00 nan% test-suite...CI_Purple/SMG2000/smg2000.test NaN 3.00 nan% Follow-up to D111727. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D112315 (cherry-picked from c9ad356)
This allows for better optimization of 'stores-of-existing-values' and possibly helps passes further down the pipeline. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D113712 (cherry-picked from 7de4104)
@swift-ci please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.