aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/AliasSetTracker.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-11 21:56:09 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-03-02 22:10:48 +0100
commit3d8f842712d49b0767832b6e3f65df2d3f19af4e (patch)
treed730c80fa2d5fc3a283fe0eda172403c02eaf481 /llvm/lib/Analysis/AliasSetTracker.cpp
parent51cdb780db3b9b46c783efcec672c4da272e9992 (diff)
downloadllvm-3d8f842712d49b0767832b6e3f65df2d3f19af4e.zip
llvm-3d8f842712d49b0767832b6e3f65df2d3f19af4e.tar.gz
llvm-3d8f842712d49b0767832b6e3f65df2d3f19af4e.tar.bz2
[LICM] Make promotion faster
Even when MemorySSA-based LICM is used, an AST is still populated for scalar promotion. As the AST has quadratic complexity, a lot of time is spent in this step despite the existing access count limit. This patch optimizes the identification of promotable stores. The idea here is pretty simple: We're only interested in must-alias mod sets of loop invariant pointers. As such, only populate the AST with loop-invariant loads and stores (anything else is definitely not promotable) and then discard any sets which alias with any of the remaining, definitely non-promotable accesses. If we promoted something, check whether this has made some other accesses loop invariant and thus possible promotion candidates. This is much faster in practice, because we need to perform AA queries for O(NumPromotable^2 + NumPromotable*NumNonPromotable) instead of O(NumTotal^2), and NumPromotable tends to be small. Additionally, promotable accesses have loop invariant pointers, for which AA is cheaper. This has a signicant positive compile-time impact. We save ~1.8% geomean on CTMark at O3, with 6% on lencod in particular and 25% on individual files. Conceptually, this change is NFC, but may not be so in practice, because the AST is only an approximation, and can produce different results depending on the order in which accesses are added. However, there is at least no impact on the number of promotions (licm.NumPromoted) in test-suite O3 configuration with this change. Differential Revision: https://reviews.llvm.org/D89264
Diffstat (limited to 'llvm/lib/Analysis/AliasSetTracker.cpp')
-rw-r--r--llvm/lib/Analysis/AliasSetTracker.cpp10
1 files changed, 0 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/AliasSetTracker.cpp b/llvm/lib/Analysis/AliasSetTracker.cpp
index 3e923c2..e43416d 100644
--- a/llvm/lib/Analysis/AliasSetTracker.cpp
+++ b/llvm/lib/Analysis/AliasSetTracker.cpp
@@ -14,7 +14,6 @@
#include "llvm/Analysis/GuardUtils.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryLocation.h"
-#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
@@ -536,15 +535,6 @@ void AliasSetTracker::add(const AliasSetTracker &AST) {
}
}
-void AliasSetTracker::addAllInstructionsInLoopUsingMSSA() {
- assert(MSSA && L && "MSSA and L must be available");
- for (const BasicBlock *BB : L->blocks())
- if (auto *Accesses = MSSA->getBlockAccesses(BB))
- for (auto &Access : *Accesses)
- if (auto *MUD = dyn_cast<MemoryUseOrDef>(&Access))
- add(MUD->getMemoryInst());
-}
-
// deleteValue method - This method is used to remove a pointer value from the
// AliasSetTracker entirely. It should be used when an instruction is deleted
// from the program to update the AST. If you don't use this, you would have