Skip to content

MemCpyOpt: clarify logic in processStoreOfLoad (NFC) #108400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading