OSDN Git Service

[ARM] Adjust AND immediates to make them cheaper to select.
authorEli Friedman <efriedma@codeaurora.org>
Fri, 10 Aug 2018 21:21:53 +0000 (21:21 +0000)
committerEli Friedman <efriedma@codeaurora.org>
Fri, 10 Aug 2018 21:21:53 +0000 (21:21 +0000)
commit0365cb9494058ba741bb633007290d77edc0ebe9
treeabb6b329d673b1343bb5a143c588239215b3b6f3
parentcffbbb125ea004ce92e7fc265def713f3e363c79
[ARM] Adjust AND immediates to make them cheaper to select.

LLVM normally prefers to minimize the number of bits set in an AND
immediate, but that doesn't always match the available ARM instructions.
In Thumb1 mode, prefer uxtb or uxth where possible; otherwise, prefer
a two-instruction sequence movs+ands or movs+bics.

Some potential improvements outlined in
ARMTargetLowering::targetShrinkDemandedConstant, but seems to work
pretty well already.

The ARMISelDAGToDAG fix ensures we don't generate an invalid UBFX
instruction due to a larger-than-expected mask. (It's orthogonal, in
some sense, but as far as I can tell it's either impossible or nearly
impossible to reproduce the bug without this change.)

According to my testing, this seems to consistently improve codesize by
a small amount by forming bic more often for ISD::AND with an immediate.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339472 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelDAGToDAG.cpp
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/ARM/ARMISelLowering.h
test/CodeGen/ARM/Windows/alloca.ll
test/CodeGen/ARM/Windows/vla.ll
test/CodeGen/ARM/and-cmpz.ll
test/CodeGen/ARM/illegal-bitfield-loadstore.ll
test/CodeGen/ARM/select_const.ll
test/CodeGen/Thumb/bic_imm.ll
test/CodeGen/Thumb/shift-and.ll