summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorAlina Sbirlea <asbirlea@google.com>2019-02-06 20:25:17 +0000
committerAlina Sbirlea <asbirlea@google.com>2019-02-06 20:25:17 +0000
commit6cba96ed52e11295e65ae5f05ebd02f594d7081c (patch)
treedf90a3221570db29715c93cfdf23828dcc32e04f /llvm/include
parentb3506bf9851ad2548c9471f8b7d36c0ab244025f (diff)
downloadbcm5719-llvm-6cba96ed52e11295e65ae5f05ebd02f594d7081c.tar.gz
bcm5719-llvm-6cba96ed52e11295e65ae5f05ebd02f594d7081c.zip
[LICM/MSSA] Add promotion to scalars by building an AliasSetTracker with MemorySSA.
Summary: Experimentally we found that promotion to scalars carries less benefits than sinking and hoisting in LICM. When using MemorySSA, we build an AliasSetTracker on demand in order to reuse the current infrastructure. We only build it if less than AccessCapForMSSAPromotion exist in the loop, a cap that is by default set to 250. This value ensures there are no runtime regressions, and there are small compile time gains for pathological cases. A much lower value (20) was found to yield a single regression in the llvm-test-suite and much higher benefits for compile times. Conservatively we set the current cap to a high value, but we will explore lowering it when MemorySSA is enabled by default. Reviewers: sanjoy, chandlerc Subscribers: nemanjai, jlebar, Prazek, george.burgess.iv, jfb, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D56625 llvm-svn: 353339
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Analysis/AliasSetTracker.h7
-rw-r--r--llvm/include/llvm/Transforms/Utils/LoopUtils.h15
-rw-r--r--llvm/include/llvm/Transforms/Utils/SSAUpdater.h4
3 files changed, 16 insertions, 10 deletions
diff --git a/llvm/include/llvm/Analysis/AliasSetTracker.h b/llvm/include/llvm/Analysis/AliasSetTracker.h
index 46f945d9ef6..34a509b7f4b 100644
--- a/llvm/include/llvm/Analysis/AliasSetTracker.h
+++ b/llvm/include/llvm/Analysis/AliasSetTracker.h
@@ -36,6 +36,8 @@ namespace llvm {
class AliasSetTracker;
class BasicBlock;
class LoadInst;
+class Loop;
+class MemorySSA;
class AnyMemSetInst;
class AnyMemTransferInst;
class raw_ostream;
@@ -341,6 +343,8 @@ class AliasSetTracker {
struct ASTCallbackVHDenseMapInfo : public DenseMapInfo<Value *> {};
AliasAnalysis &AA;
+ MemorySSA *MSSA;
+ Loop *L;
ilist<AliasSet> AliasSets;
using PointerMapType = DenseMap<ASTCallbackVH, AliasSet::PointerRec *,
@@ -353,6 +357,8 @@ public:
/// Create an empty collection of AliasSets, and use the specified alias
/// analysis object to disambiguate load and store addresses.
explicit AliasSetTracker(AliasAnalysis &aa) : AA(aa) {}
+ explicit AliasSetTracker(AliasAnalysis &aa, MemorySSA *mssa, Loop *l)
+ : AA(aa), MSSA(mssa), L(l) {}
~AliasSetTracker() { clear(); }
/// These methods are used to add different types of instructions to the alias
@@ -377,6 +383,7 @@ public:
void add(BasicBlock &BB); // Add all instructions in basic block
void add(const AliasSetTracker &AST); // Add alias relations from another AST
void addUnknown(Instruction *I);
+ void addAllInstructionsInLoopUsingMSSA();
void clear();
diff --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
index 44df77c2ff3..fd082664857 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -40,6 +40,7 @@ class BasicBlock;
class DataLayout;
class Loop;
class LoopInfo;
+class MemoryAccess;
class MemorySSAUpdater;
class OptimizationRemarkEmitter;
class PredicatedScalarEvolution;
@@ -148,14 +149,12 @@ void deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE,
/// LoopInfo, DominatorTree, Loop, AliasSet information for all instructions
/// of the loop and loop safety information as arguments.
/// Diagnostics is emitted via \p ORE. It returns changed status.
-bool promoteLoopAccessesToScalars(const SmallSetVector<Value *, 8> &,
- SmallVectorImpl<BasicBlock *> &,
- SmallVectorImpl<Instruction *> &,
- PredIteratorCache &, LoopInfo *,
- DominatorTree *, const TargetLibraryInfo *,
- Loop *, AliasSetTracker *,
- ICFLoopSafetyInfo *,
- OptimizationRemarkEmitter *);
+bool promoteLoopAccessesToScalars(
+ const SmallSetVector<Value *, 8> &, SmallVectorImpl<BasicBlock *> &,
+ SmallVectorImpl<Instruction *> &, SmallVectorImpl<MemoryAccess *> &,
+ PredIteratorCache &, LoopInfo *, DominatorTree *, const TargetLibraryInfo *,
+ Loop *, AliasSetTracker *, MemorySSAUpdater *, ICFLoopSafetyInfo *,
+ OptimizationRemarkEmitter *);
/// Does a BFS from a given node to all of its children inside a given loop.
/// The returned vector of nodes includes the starting point.
diff --git a/llvm/include/llvm/Transforms/Utils/SSAUpdater.h b/llvm/include/llvm/Transforms/Utils/SSAUpdater.h
index d65ccfaeca9..22b2295cc9d 100644
--- a/llvm/include/llvm/Transforms/Utils/SSAUpdater.h
+++ b/llvm/include/llvm/Transforms/Utils/SSAUpdater.h
@@ -147,7 +147,7 @@ public:
/// Insts is a list of loads and stores to promote, and Name is the basename
/// for the PHIs to insert. After this is complete, the loads and stores are
/// removed from the code.
- void run(const SmallVectorImpl<Instruction *> &Insts) const;
+ void run(const SmallVectorImpl<Instruction *> &Insts);
/// Return true if the specified instruction is in the Inst list.
///
@@ -158,7 +158,7 @@ public:
/// This hook is invoked after all the stores are found and inserted as
/// available values.
- virtual void doExtraRewritesBeforeFinalDeletion() const {}
+ virtual void doExtraRewritesBeforeFinalDeletion() {}
/// Clients can choose to implement this to get notified right before
/// a load is RAUW'd another value.
OpenPOWER on IntegriCloud