[llvm] 7e9bd12 - MemCpyOpt: clarify logic in processStoreOfLoad (NFC) (#108400)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 12 13:16:46 PDT 2024
Author: Ramkumar Ramachandra
Date: 2024-09-12T21:16:43+01:00
New Revision: 7e9bd12cd9ebb1f14c3716d5e45fb88aff23e671
URL: https://github.com/llvm/llvm-project/commit/7e9bd12cd9ebb1f14c3716d5e45fb88aff23e671
DIFF: https://github.com/llvm/llvm-project/commit/7e9bd12cd9ebb1f14c3716d5e45fb88aff23e671.diff
LOG: MemCpyOpt: clarify logic in processStoreOfLoad (NFC) (#108400)
Added:
Modified:
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 4c8ecf855b210f..1d67773585d593 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -661,18 +661,11 @@ bool MemCpyOptPass::processStoreOfLoad(StoreInst *SI, LoadInst *LI,
}
}
- // We found an instruction that may write to the loaded memory.
- // We can try to promote at this position instead of the store
+ // If we found an instruction that may write to the loaded memory,
+ // we can try to promote at this position instead of the store
// position if nothing aliases the store memory after this and the store
// destination is not in the range.
- if (P && P != SI) {
- if (!moveUp(SI, P, LI))
- P = nullptr;
- }
-
- // If a valid insertion position is found, then we can promote
- // the load/store pair to a memcpy.
- if (P) {
+ if (P == SI || moveUp(SI, P, LI)) {
// If we load from memory that may alias the memory we store to,
// memmove must be used to preserve semantic. If not, memcpy can
// be used. Also, if we load from constant memory, memcpy can be used
More information about the llvm-commits
mailing list