[ARM] Modify codegen for memcpy intrinsic to prefer LDM/STM.
authorScott Douglass <sdouglass@arm.com>
Mon, 5 Oct 2015 14:49:54 +0000 (14:49 +0000)
committerScott Douglass <sdouglass@arm.com>
Mon, 5 Oct 2015 14:49:54 +0000 (14:49 +0000)
commitab6273be70d34e95ebc4e131d1245dbed3584668
tree058e51ccbe08f1654289270badd14840a4662d8b
parent60fe48f86639ab4472d186bc97e7676f269cae18
[ARM] Modify codegen for memcpy intrinsic to prefer LDM/STM.

We were previously codegen'ing memcpy 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 achieving better codegen is to create MEMCPY pseudo
instructions, attach scratch virtual registers to them and then, post register
allocation, expand the MEMCPYs into LDM/STM pairs using the scratch registers.
The register allocator will have picked arbitrary registers which we sort when
expanding the MEMCPY. This approach also avoids the need to repeatedly calculate
offsets which ultimately ought to be eliminated pre-RA in order to decrease
register pressure.

Fixes PR9199 and PR23768.

[This is based on Peter Collingbourne's r238473 which was reverted.]

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

Change-Id: I727543c2e94136e0f80b8e22d5642d7b9ee5b458
Author: Peter Collingbourne <peter@pcc.me.uk>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249322 91177308-0d34-0410-b5e6-96231b3b80d8
14 files changed:
lib/Target/ARM/ARMBaseInstrInfo.cpp
lib/Target/ARM/ARMBaseInstrInfo.h
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
lib/Target/ARM/ARMInstrInfo.td
lib/Target/ARM/ARMInstrThumb.td
lib/Target/ARM/ARMSelectionDAGInfo.cpp
lib/Target/ARM/Thumb2SizeReduction.cpp
test/CodeGen/ARM/ldm-stm-base-materialization.ll [new file with mode: 0644]
test/CodeGen/ARM/load-store-flags.ll
test/CodeGen/ARM/memcpy-ldm-stm.ll [new file with mode: 0644]
test/CodeGen/Thumb/ldm-stm-base-materialization-thumb2.ll [new file with mode: 0644]
test/CodeGen/Thumb/ldm-stm-base-materialization.ll
test/CodeGen/Thumb/thumb-memcpy-ldm-stm.ll [deleted file]