[llvm] r278641 - [ScopedNoAliasAA] Remove an unneccesary set

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 14 17:13:04 PDT 2016


Author: majnemer
Date: Sun Aug 14 19:13:04 2016
New Revision: 278641

URL: http://llvm.org/viewvc/llvm-project?rev=278641&view=rev
Log:
[ScopedNoAliasAA] Remove an unneccesary set

We are trying to prove that one group of operands is a subset of
another.  We did this by populating two Sets and determining that every
element within one was inside the other.

However, this is unnecessary.  We can simply construct a single set and
test if each operand is within it.

Modified:
    llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h
    llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp

Modified: llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h?rev=278641&r1=278640&r2=278641&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScopedNoAliasAA.h Sun Aug 14 19:13:04 2016
@@ -42,8 +42,6 @@ public:
 
 private:
   bool mayAliasInScopes(const MDNode *Scopes, const MDNode *NoAlias) const;
-  void collectMDInDomain(const MDNode *List, const MDNode *Domain,
-                         SmallPtrSetImpl<const MDNode *> &Nodes) const;
 };
 
 /// Analysis pass providing a never-invalidated alias analysis result.

Modified: llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp?rev=278641&r1=278640&r2=278641&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp (original)
+++ llvm/trunk/lib/Analysis/ScopedNoAliasAA.cpp Sun Aug 14 19:13:04 2016
@@ -127,15 +127,6 @@ ModRefInfo ScopedNoAliasAAResult::getMod
   return AAResultBase::getModRefInfo(CS1, CS2);
 }
 
-void ScopedNoAliasAAResult::collectMDInDomain(
-    const MDNode *List, const MDNode *Domain,
-    SmallPtrSetImpl<const MDNode *> &Nodes) const {
-  for (const MDOperand &MDOp : List->operands())
-    if (const MDNode *MD = dyn_cast<MDNode>(MDOp))
-      if (AliasScopeNode(MD).getDomain() == Domain)
-        Nodes.insert(MD);
-}
-
 bool ScopedNoAliasAAResult::mayAliasInScopes(const MDNode *Scopes,
                                              const MDNode *NoAlias) const {
   if (!Scopes || !NoAlias)
@@ -151,19 +142,21 @@ bool ScopedNoAliasAAResult::mayAliasInSc
   // We alias unless, for some domain, the set of noalias scopes in that domain
   // is a superset of the set of alias scopes in that domain.
   for (const MDNode *Domain : Domains) {
-    SmallPtrSet<const MDNode *, 16> NANodes, ScopeNodes;
-    collectMDInDomain(NoAlias, Domain, NANodes);
-    collectMDInDomain(Scopes, Domain, ScopeNodes);
-    if (!ScopeNodes.size())
-      continue;
+    SmallPtrSet<const MDNode *, 16> NANodes;
+    for (const MDOperand &MDOp : NoAlias->operands())
+      if (const MDNode *MD = dyn_cast<MDNode>(MDOp))
+        if (AliasScopeNode(MD).getDomain() == Domain)
+          NANodes.insert(MD);
 
-    // To not alias, all of the nodes in ScopeNodes must be in NANodes.
+    // To not alias, all of the nodes in Scopes must be in NANodes.
     bool FoundAll = true;
-    for (const MDNode *SMD : ScopeNodes)
-      if (!NANodes.count(SMD)) {
-        FoundAll = false;
-        break;
-      }
+    for (const MDOperand &MDOp : Scopes->operands())
+      if (const MDNode *SMD = dyn_cast<MDNode>(MDOp))
+        if (AliasScopeNode(SMD).getDomain() == Domain)
+          if (!NANodes.count(SMD)) {
+            FoundAll = false;
+            break;
+          }
 
     if (FoundAll)
       return false;




More information about the llvm-commits mailing list