[SDAG] Introduce a new BITREVERSE node along with a corresponding LLVM intrinsic
authorJames Molloy <james.molloy@arm.com>
Thu, 12 Nov 2015 12:29:09 +0000 (12:29 +0000)
committerJames Molloy <james.molloy@arm.com>
Thu, 12 Nov 2015 12:29:09 +0000 (12:29 +0000)
commitfdd6e1b2e5e139a574f19788c71ae44dfaafa404
treec8e96a7237f44703a72b2942361c7251060f40dc
parent29020c0a61eb294acc5df86b2109f411916ec969
[SDAG] Introduce a new BITREVERSE node along with a corresponding LLVM intrinsic

Several backends have instructions to reverse the order of bits in an integer. Conceptually matching such patterns is similar to @llvm.bswap, and it was mentioned in http://reviews.llvm.org/D14234 that it would be best if these patterns were matched in InstCombine instead of reimplemented in every different target.

This patch introduces an intrinsic @llvm.bitreverse.i* that operates similarly to @llvm.bswap. For plumbing purposes there is also a new ISD node ISD::BITREVERSE, with simple expansion and promotion support.

The intention is that InstCombine's BSWAP detection logic will be extended to support BITREVERSE too, and @llvm.bitreverse intrinsics emitted (if the backend supports lowering it efficiently).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252878 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
docs/LangRef.rst
include/llvm/CodeGen/ISDOpcodes.h
include/llvm/IR/Intrinsics.td
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeTypes.h
lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
lib/CodeGen/TargetLoweringBase.cpp
test/CodeGen/AArch64/bitreverse.ll [new file with mode: 0644]
test/CodeGen/PowerPC/bitreverse.ll [new file with mode: 0644]
test/CodeGen/X86/bitreverse.ll [new file with mode: 0644]