summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2018-03-15 18:12:27 +0000
committerPhilip Reames <listmail@philipreames.com>2018-03-15 18:12:27 +0000
commit422024a1b70be2745733d83aacca14a915e762c7 (patch)
tree92447b10a228da7e91137e716b9da876c7212df3 /llvm/lib/Transforms/Scalar/EarlyCSE.cpp
parentc99042ba973be37d9a5bcbb258f83251bf36b673 (diff)
downloadbcm5719-llvm-422024a1b70be2745733d83aacca14a915e762c7.tar.gz
bcm5719-llvm-422024a1b70be2745733d83aacca14a915e762c7.zip
[EarlyCSE] Don't hide earler invariant.scopes
If we've already established an invariant scope with an earlier generation, we don't want to hide it in the scoped hash table with one with a later generation. I noticed this when working on the invariant-load handling, but it also applies to the invariant.start case as well. Without this change, my previous patch for invariant-load regresses some cases, so I'm pushing this without waiting for review. This is why you don't make last minute tweaks to patches to catch "obvious cases" after it's already been reviewed. Bad Philip! llvm-svn: 327655
Diffstat (limited to 'llvm/lib/Transforms/Scalar/EarlyCSE.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/EarlyCSE.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
index 3f70ee49ad9..6f03023cab9 100644
--- a/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ b/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -799,7 +799,9 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
continue;
auto *CI = cast<CallInst>(Inst);
MemoryLocation MemLoc = MemoryLocation::getForArgument(CI, 1, TLI);
- AvailableInvariants.insert(MemLoc, CurrentGeneration);
+ // Don't start a scope if we already have a better one pushed
+ if (!AvailableInvariants.count(MemLoc))
+ AvailableInvariants.insert(MemLoc, CurrentGeneration);
continue;
}
@@ -888,9 +890,12 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
if (MemInst.isInvariantLoad()) {
// If we pass an invariant load, we know that memory location is
// indefinitely constant from the moment of first dereferenceability.
- // We conservatively treat the invariant_load as that moment.
+ // We conservatively treat the invariant_load as that moment. If we
+ // pass a invariant load after already establishing a scope, don't
+ // restart it since we want to preserve the earliest point seen.
auto MemLoc = MemoryLocation::get(Inst);
- AvailableInvariants.insert(MemLoc, CurrentGeneration);
+ if (!AvailableInvariants.count(MemLoc))
+ AvailableInvariants.insert(MemLoc, CurrentGeneration);
}
// If we have an available version of this load, and if it is the right
OpenPOWER on IntegriCloud