[llvm] [LoopInterchange] Make the entries of the Dependency Matrix unique (PR #116195)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 02:03:35 PST 2024


================
@@ -156,7 +158,13 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level,
           Dep.push_back('I');
         }
 
-        DepMatrix.push_back(Dep);
+        // Make sure we only add unique entries to the dependency matrix.
+        std::string DepStr = std::string(Dep.begin(), Dep.end());
+        if (!Seen.count(DepStr)) {
+          Seen.insert(DepStr);
----------------
nikic wrote:

You should directly call insert and check the return value. That saves one hash table lookup.

https://github.com/llvm/llvm-project/pull/116195


More information about the llvm-commits mailing list