[MemCpyOpt] Turn memcpy from just-memset'd source into memset.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Sat, 16 May 2015 01:32:26 +0000 (01:32 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Sat, 16 May 2015 01:32:26 +0000 (01:32 +0000)
commit8081057fca87440166a0d0e02c74a8ff0354d978
tree858e23eb96ccd428adcb290a8969fa9a79268583
parent487db4685a6bdc0ecb1edb1822299010712570af
[MemCpyOpt] Turn memcpy from just-memset'd source into memset.

There's no point in copying around constants, so, when all else fails,
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 r235232 for copy constructors, this can occur in move constructors.

Differential Revision: http://reviews.llvm.org/D9682

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237506 91177308-0d34-0410-b5e6-96231b3b80d8
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 [new file with mode: 0644]