[llvm] 9675e3f - [LV] Address post-commit NFC comments in interleave

Anna Thomas via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 13:24:48 PDT 2023


Author: Anna Thomas
Date: 2023-07-14T16:24:07-04:00
New Revision: 9675e3fa81e5907ea3015cfc9e2adca3d2adf4c2

URL: https://github.com/llvm/llvm-project/commit/9675e3fa81e5907ea3015cfc9e2adca3d2adf4c2
DIFF: https://github.com/llvm/llvm-project/commit/9675e3fa81e5907ea3015cfc9e2adca3d2adf4c2.diff

LOG: [LV] Address post-commit NFC comments in interleave

Addressed most of post-commit comments in D154309.

Added: 
    

Modified: 
    llvm/lib/Analysis/VectorUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index 5ec685a231952d..87f0bb6904776c 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -1150,23 +1150,22 @@ void InterleavedAccessInfo::analyzeInterleaving(
     // Initialize a group for B if it has an allowable stride. Even if we don't
     // create a group for B, we continue with the bottom-up algorithm to ensure
     // we don't break any of B's dependences.
-    InterleaveGroup<Instruction> *Group = nullptr;
+    InterleaveGroup<Instruction> *GroupB = nullptr;
     if (isStrided(DesB.Stride) &&
         (!isPredicated(B->getParent()) || EnablePredicatedInterleavedMemAccesses)) {
-      Group = getInterleaveGroup(B);
-      if (!Group) {
+      GroupB = getInterleaveGroup(B);
+      if (!GroupB) {
         LLVM_DEBUG(dbgs() << "LV: Creating an interleave group with:" << *B
                           << '\n');
-        Group = createInterleaveGroup(B, DesB.Stride, DesB.Alignment);
-      }
-      if (B->mayWriteToMemory())
-        StoreGroups.insert(Group);
-      else {
+        GroupB = createInterleaveGroup(B, DesB.Stride, DesB.Alignment);
+      } else if (CompletedLoadGroups.contains(GroupB)) {
         // Skip B if no new instructions can be added to its load group.
-        if (CompletedLoadGroups.contains(Group))
-          continue;
-        LoadGroups.insert(Group);
+        continue;
       }
+      if (B->mayWriteToMemory())
+        StoreGroups.insert(GroupB);
+      else
+        LoadGroups.insert(GroupB);
     }
 
     for (auto AI = std::next(BI); AI != E; ++AI) {
@@ -1211,13 +1210,11 @@ void InterleavedAccessInfo::analyzeInterleaving(
         // be added to B's interleave group, because this would mean the load B
         // would need to be moved across store A. Mark the interleave group as
         // complete.
-        if (isInterleaved(B) && isa<LoadInst>(B)) {
-          InterleaveGroup<Instruction> *LoadGroup = getInterleaveGroup(B);
-
+        if (GroupB && isa<LoadInst>(B)) {
           LLVM_DEBUG(dbgs() << "LV: Marking interleave group for " << *B
                             << " as complete.\n");
 
-          CompletedLoadGroups.insert(LoadGroup);
+          CompletedLoadGroups.insert(GroupB);
         }
 
         // If a dependence exists and A is not already in a group (or it was
@@ -1277,18 +1274,18 @@ void InterleavedAccessInfo::analyzeInterleaving(
       // The index of A is the index of B plus A's distance to B in multiples
       // of the size.
       int IndexA =
-          Group->getIndex(B) + DistanceToB / static_cast<int64_t>(DesB.Size);
+          GroupB->getIndex(B) + DistanceToB / static_cast<int64_t>(DesB.Size);
 
       // Try to insert A into B's group.
-      if (Group->insertMember(A, IndexA, DesA.Alignment)) {
+      if (GroupB->insertMember(A, IndexA, DesA.Alignment)) {
         LLVM_DEBUG(dbgs() << "LV: Inserted:" << *A << '\n'
                           << "    into the interleave group with" << *B
                           << '\n');
-        InterleaveGroupMap[A] = Group;
+        InterleaveGroupMap[A] = GroupB;
 
         // Set the first load in program order as the insert position.
         if (A->mayReadFromMemory())
-          Group->setInsertPos(A);
+          GroupB->setInsertPos(A);
       }
     } // Iteration over A accesses.
   }   // Iteration over B accesses.


        


More information about the llvm-commits mailing list