Skip to content

Commit 4740e98

Browse files
committed
[LoopDist] Add some runtime checks for cross partition loads - p2
Add back in getInstructionsForAccess as query for Instructions modifying memory to mark cross partition accesses.
1 parent ab696fb commit 4740e98

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

llvm/lib/Transforms/Scalar/LoopDistribute.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ class InstPartitionContainer {
504504
Value *Ptr = RtPtrCheck->Pointers[I].PointerValue;
505505
auto Instructions =
506506
LAI.getInstructionsForAccess(Ptr, RtPtrCheck->Pointers[I].IsWritePtr);
507+
const MemoryDepChecker &DC = LAI.getDepChecker();
508+
bool IsWritePtr = !RtPtrCheck->Pointers[I].IsWritePtr;
509+
if (!DC.getOrderForAccess(Ptr, IsWritePtr).empty()) {
510+
auto AltInstructions = LAI.getInstructionsForAccess(Ptr, IsWritePtr);
511+
Instructions.append(AltInstructions.begin(), AltInstructions.end());
512+
}
507513

508514
int &Partition = PtrToPartitions[I];
509515
// First set it to uninitialized.
@@ -521,21 +527,6 @@ class InstPartitionContainer {
521527
Partition = -1;
522528
}
523529
assert(Partition != -2 && "Pointer not belonging to any partition");
524-
// All the store context uses of our address were processed,
525-
// Now make sure we don't have cross partition loads.
526-
if (RtPtrCheck->Pointers[I].IsWritePtr) {
527-
if (Ptr->hasOneUse() || Partition == -1)
528-
continue;
529-
530-
for (User *U : Ptr->users())
531-
if (auto *CurLoad = dyn_cast<LoadInst>(U))
532-
if (L->contains(CurLoad->getParent()))
533-
if (Partition != (int)this->InstToPartitionId[CurLoad]) {
534-
// -1 means belonging to multiple partitions.
535-
Partition = -1;
536-
break;
537-
}
538-
}
539530
}
540531

541532
return PtrToPartitions;

0 commit comments

Comments
 (0)