[llvm] [InstCombine] Forward memcpy source to load instruction (PR #140249)

via llvm-commits llvm-commits at lists.llvm.org
Sat May 24 19:44:31 PDT 2025


dianqk wrote:

> Can we start in a more conservative way, by ensuring that the load can be CSEed (query `FindAvailableLoadedValue` recursively with forwarded memcpy source), or the memcpy has only one user in MemorySSA?

IIUC, both cannot resolve [llvm/test/Transforms/PhaseOrdering/pr137810-forward-load.ll](https://github.com/llvm/llvm-project/pull/140249/files#diff-227580960f6d318761db200c8b44a02873190c92a4cc4e74838460403f8f4125). (Please correct me if I've misunderstood your point.)

The [original IR](https://godbolt.org/z/8zq4jdWP3) only has this one `MemoryDef`, which seems like an opportunity for optimization.

https://github.com/llvm/llvm-project/pull/140249


More information about the llvm-commits mailing list