[PATCH] New Loop Distribution pass

Arnold Schwaighofer aschwaighofer at apple.com
Wed May 13 15:26:54 PDT 2015


This LGTM. Nice work!


================
Comment at: lib/Transforms/Scalar/LoopDistribute.cpp:147
@@ +146,3 @@
+
+  /// \brief Moves \p Other into this partition.  Other becomes empty after
+  /// this.
----------------
Comment: It is the other way round. The code moves 'this' to the 'Other' partition.

================
Comment at: lib/Transforms/Scalar/LoopDistribute.cpp:575
@@ +574,3 @@
+  void mergeAdjacentPartitionsIf(UnaryPredicate Predicate) {
+    for (auto I = PartitionContainer.begin(); I != PartitionContainer.end();) {
+      auto &FirstPartition = *I;
----------------
Can we rewrite this nested loop to something like:

  InstPartion *PrevMatch = nullptr;
  for (auto It = PC.begin(); It != PC.end(); ) {
    auto DoesMatch = Predicate(*It);
    if (PreMatch == nullptr && DoesMatch) {
       PrevMatch = *It
       ++It;
    } else if (PreMatch != nullptr && DoesMatch) {
      *It->move_to(PrevMatch);
       It = PC.erase(It);
    } else {
      PrevMatch = nullptr;
      ++It;
    }
  }

http://reviews.llvm.org/D8831

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list