Skip to content

Commit 63d5c7b

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 63d5c7b

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

llvm/lib/Transforms/Scalar/LoopDistribute.cpp

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,14 +527,31 @@ class InstPartitionContainer {
527527
if (Ptr->hasOneUse() || Partition == -1)
528528
continue;
529529

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-
}
530+
bool ProcessLoads = false;
531+
for (auto *U : Ptr->users()) {
532+
auto *CurLoad = dyn_cast<LoadInst>(U);
533+
if (!CurLoad)
534+
continue;
535+
if (!L->contains(CurLoad->getParent()))
536+
continue;
537+
538+
ProcessLoads = true;
539+
break;
540+
}
541+
542+
if (!ProcessLoads)
543+
continue;
544+
545+
const bool IsWritePtr = false;
546+
auto ReadInstructions = LAI.getInstructionsForAccess(Ptr, IsWritePtr);
547+
for (Instruction *ReadInst : ReadInstructions) {
548+
if (Partition == (int)this->InstToPartitionId[ReadInst])
549+
continue;
550+
551+
// -1 means belonging to multiple partitions.
552+
Partition = -1;
553+
break;
554+
}
538555
}
539556
}
540557

0 commit comments

Comments
 (0)