OSDN Git Service

[AArch64] Improve getUsefulBitsForUse for narrow stores.
authorChad Rosier <mcrosier@codeaurora.org>
Wed, 11 May 2016 20:19:54 +0000 (20:19 +0000)
committerChad Rosier <mcrosier@codeaurora.org>
Wed, 11 May 2016 20:19:54 +0000 (20:19 +0000)
commitfea2d4d86c44633ca1820dfd28da3d05338337e2
treef0803ca8185ce19012c7588840b4e8474f773ea6
parent678ba5a1172c133d32736bb593d5b145c619517f
[AArch64] Improve getUsefulBitsForUse for narrow stores.

For narrow stores (e.g., strb, srth) we know the upper bits of the register are
unused/not useful. In some cases we can use this information to eliminate
unnecessary instructions.

For example, without this patch we generate (from the 2nd test case):

 ldr w8, [x0]
 and w8, w8, #0xfff0
 bfxil w8, w2, #16, #4
 strh w8, [x1]

and after the patch the 'and' is removed:

 ldr w8, [x0]
 bfxil w8, w2, #16, #4
 strh w8, [x1]
 ret

During the lowering of the bitfield insert instruction the 'and' is eliminated
because we know the upper 16-bits that are masked off are unused and the lower
4-bits that are masked off are overwritten by the insert itself. Therefore, the
'and' is unnecessary.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269226 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
test/CodeGen/AArch64/bitfield-insert.ll