OSDN Git Service

[ARM] Fix lowering of misaligned memcpy/memset
authorJohn Brawn <john.brawn@arm.com>
Fri, 26 May 2017 13:59:12 +0000 (13:59 +0000)
committerJohn Brawn <john.brawn@arm.com>
Fri, 26 May 2017 13:59:12 +0000 (13:59 +0000)
commitbafb2e66d85af00ba60213496cb2e5f1415f514c
treef833d56dbc72916b5b68332dac45ac7f9d85da70
parenta0b8f33f3b5aba0cdf581cdbccc7348c3449cfe2
[ARM] Fix lowering of misaligned memcpy/memset

Currently getOptimalMemOpType returns i32 for large enough sizes without
checking for alignment, leading to poor code generation when misaligned accesses
aren't permitted as we generate a word store then later split it up into byte
stores. This means we inadvertantly go over the MaxStoresPerMemcpy limit and for
memset we splat the memset value into a word then immediately split it up
again.

Fix this by leaving it up to FindOptimalMemOpLowering to figure out which type
to use, but also fix a bug there where it wasn't correctly checking if
misaligned memory accesses are allowed.

Differential Revision: https://reviews.llvm.org/D33442

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303990 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/memcpy-inline.ll
test/CodeGen/ARM/memset-inline.ll