[MemCpyOpt] Allow variable lengths in memcpy optimizer
authorOlle Fredriksson <fredriksson.olle@gmail.com>
Wed, 21 Apr 2021 20:48:28 +0000 (22:48 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 21 Apr 2021 21:23:38 +0000 (23:23 +0200)
commitf5446b769a7929806f72256fccd4826d66502e59
treeb76667497d9a1107418bcb3dd07e046f97e63c70
parent6331680ad2ad000fdaf7e72f3c1880c7908ffa25
[MemCpyOpt] Allow variable lengths in memcpy optimizer

This makes the memcpy-memcpy and memcpy-memset optimizations work for
variable sizes as long as they are equal, relaxing the old restriction
that they are constant integers. If they're not equal, the old
requirement that they are constant integers with certain size
restrictions is used.

The implementation works by pushing the length tests further down in the
code, which reveals some places where it's enough that the lengths are
equal (but not necessarily constant).

Differential Revision: https://reviews.llvm.org/D100870
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
llvm/test/Transforms/MemCpyOpt/variable-sized-memcpy-memcpy.ll [new file with mode: 0644]
llvm/test/Transforms/MemCpyOpt/variable-sized-memcpy-uninit.ll [new file with mode: 0644]
llvm/test/Transforms/MemCpyOpt/variable-sized-memset-memcpy.ll [new file with mode: 0644]