[llvm] MemCpyOpt: clarify logic in processStoreOfLoad (NFC) (PR #108400)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 12 07:28:45 PDT 2024
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/108400
None
>From 700db3b7b3e8104eb6ae2369c5086e2865bae311 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Thu, 12 Sep 2024 15:23:15 +0100
Subject: [PATCH] MemCpyOpt: clarify logic in processStoreOfLoad (NFC)
---
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 3f15fa2163d270..32f2b025db45ca 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