OSDN Git Service

[ARM] Lower lower saturate to 0 and lower saturate to -1 using bit-operations
authorPablo Barrio <pablo.barrio@arm.com>
Wed, 31 Jan 2018 13:20:10 +0000 (13:20 +0000)
committerPablo Barrio <pablo.barrio@arm.com>
Wed, 31 Jan 2018 13:20:10 +0000 (13:20 +0000)
commitd69d8351ae618170ce9af3a694f53c79f8274ec3
tree93f31ae96babacf6edd55912ecfbf7cf0d2830db
parentb659d3fca5d24c25ee73f979edb382f7f24e05e2
[ARM] Lower lower saturate to 0 and lower saturate to -1 using bit-operations

Summary:
Expressions of the form x < 0 ? 0 :  x; and x < -1 ? -1 : x can be lowered using bit-operations instead of branching or conditional moves

In thumb-mode this results in a two-instruction sequence, a shift followed by a bic or or while in ARM/thumb2 mode that has flexible second operand the shift can be folded into a single bic/or instructions. In most cases this results in smaller code and possibly less branches, and in no case larger than before.

Patch by Marten Svanfeldt.

Reviewers: fhahn, pbarrio

Reviewed By: pbarrio

Subscribers: efriedma, rogfer01, aemerson, javed.absar, kristof.beyls, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323869 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMISelLowering.cpp
test/CodeGen/ARM/atomic-op.ll
test/CodeGen/ARM/sat-to-bitop.ll [new file with mode: 0644]
test/CodeGen/ARM/select.ll
test/CodeGen/Thumb/select.ll