Thumb2: Modify codegen for memcpy intrinsic to prefer LDM/STM.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 28 May 2015 20:02:45 +0000 (20:02 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 28 May 2015 20:02:45 +0000 (20:02 +0000)
commit27565d6185d8e789749d9a5681d06b81b02df297
tree5ddbb56778a5b0a83051926c59ff9aab77917924
parent9417bdcc55a34c0299552edc50df66d76c6ae175
Thumb2: Modify codegen for memcpy intrinsic to prefer LDM/STM.

We were previously codegen'ing these as regular load/store operations and
hoping that the register allocator would allocate registers in ascending order
so that we could apply an LDM/STM combine after register allocation. According
to the commit that first introduced this code (r37179), we planned to teach
the register allocator to allocate the registers in ascending order. This
never got implemented, and up to now we've been stuck with very poor codegen.

A much simpler approach for achiveing better codegen is to create LDM/STM
instructions with identical sets of virtual registers, let the register
allocator pick arbitrary registers and order register lists when printing an
MCInst. This approach also avoids the need to repeatedly calculate offsets
which ultimately ought to be eliminated pre-RA in order to decrease register
pressure.

This is implemented by lowering the memcpy intrinsic to a series of SD-only
MCOPY pseudo-instructions which performs a memory copy using a given number
of registers. During SD->MI lowering, we lower MCOPY to LDM/STM. This is a
little unusual, but it avoids the need to encode register lists in the SD,
and we can take advantage of SD use lists to decide whether to use the _UPD
variant of the instructions.

Fixes PR9199.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238473 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
lib/Target/ARM/ARMInstrInfo.td
lib/Target/ARM/ARMSelectionDAGInfo.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp
lib/Target/ARM/Thumb2SizeReduction.cpp
test/CodeGen/Thumb/ldm-stm-base-materialization.ll
test/CodeGen/Thumb/thumb-memcpy-ldm-stm.ll