[PATCH] [MemCpyOpt] Turn memcpy from just-memset'd source into memset.

Ahmed Bougacha ahmed.bougacha at gmail.com
Mon May 11 14:49:36 PDT 2015


Hi jmolloy, dberlin,

There's no point in copying around constants, so, when all else fails, I think we can still transform memcpy of memset into two independent memsets.  To quote the example, we can turn:

   memset(dst1, c, dst1_size);
   memcpy(dst2, dst1, dst2_size);

into:

   memset(dst1, c, dst1_size);
   memset(dst2, c, dst2_size);

When dst2_size <= dst1_size.

Like D498 for copy constructors, I think this pattern can occur in move constructors.

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D9682

Files:
  lib/Transforms/Scalar/MemCpyOptimizer.cpp
  test/Transforms/MemCpyOpt/callslot_deref.ll
  test/Transforms/MemCpyOpt/memcpy-to-memset-with-lifetimes.ll
  test/Transforms/MemCpyOpt/memset-memcpy-to-2x-memset.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9682.25513.patch
Type: text/x-patch
Size: 10132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150511/761ccd12/attachment.bin>


More information about the llvm-commits mailing list