Skip to content

Commit 7e9bd12

Browse files
authored
MemCpyOpt: clarify logic in processStoreOfLoad (NFC) (#108400)
1 parent aa34657 commit 7e9bd12

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -661,18 +661,11 @@ bool MemCpyOptPass::processStoreOfLoad(StoreInst *SI, LoadInst *LI,
661661
}
662662
}
663663

664-
// We found an instruction that may write to the loaded memory.
665-
// We can try to promote at this position instead of the store
664+
// If we found an instruction that may write to the loaded memory,
665+
// we can try to promote at this position instead of the store
666666
// position if nothing aliases the store memory after this and the store
667667
// destination is not in the range.
668-
if (P && P != SI) {
669-
if (!moveUp(SI, P, LI))
670-
P = nullptr;
671-
}
672-
673-
// If a valid insertion position is found, then we can promote
674-
// the load/store pair to a memcpy.
675-
if (P) {
668+
if (P == SI || moveUp(SI, P, LI)) {
676669
// If we load from memory that may alias the memory we store to,
677670
// memmove must be used to preserve semantic. If not, memcpy can
678671
// be used. Also, if we load from constant memory, memcpy can be used

0 commit comments

Comments
 (0)