[PATCH] D37939: [Mem2Reg] Also handle memcpy

Keno Fischer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 15:39:51 PDT 2017


loladiro created this revision.
Herald added a reviewer: dberlin.

In julia, when we know we're moving data between two memory locations,
we always emit that as a memcpy rather than a load/store pair. However,
this can give worse optimization results in certain cases because some
optimizations that can handle load/store pairs cannot handle memcpys.
Mem2reg is one of these optimizations. This patch adds rudamentary
support for mem2reg for recognizing memcpys that cover the whole alloca
we're promoting. While several more sophisticated passes (SROA, GVN)
can get similar optimizations, it is preferable to have these kinds
of cases caught early to expose optimization opportunities before
getting to these later passes. The approach taken here is to split
the memcpy into a load/store pair early (after legality analysis)
and retain the rest of the analysis only on loads/stores. It would
be possible of course to leave the memcpy as is and generate the
left over load or store only on demand. However, that would entail
a significantly larger patch for unclear benefit.


https://reviews.llvm.org/D37939

Files:
  lib/Transforms/Utils/PromoteMemoryToRegister.cpp
  test/Transforms/Mem2Reg/memcpy.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37939.115514.patch
Type: text/x-patch
Size: 8982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170915/44d31ccb/attachment.bin>


More information about the llvm-commits mailing list