[SelectionDAG] Optimization of BITREVERSE legalization for power-of-2 integer scalar...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 22 Jul 2016 16:46:25 +0000 (16:46 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 22 Jul 2016 16:46:25 +0000 (16:46 +0000)
commit820f87a72d872987a95d1e5931f1dd7656f2ec0a
tree1d46ae62cb0fac56b5c103fd081e48c45f31423b
parentc27f1b7182b41a262b8415afc03d21aa20326317
[SelectionDAG] Optimization of BITREVERSE legalization for power-of-2 integer scalar/vector types

An extension of D19978, this patch replaces the default BITREVERSE evaluation of individual bit masks+shifts with block mask+shifts when we have integer elements of power-of-2 bits in size.

After calling BSWAP to reverse the order of the constituent bytes (which typically follows a similar approach), every neighbouring 4-bits, 2-bits and finally 1-bit pairs are masked off and swapped over with shifts.

In doing so we can significantly reduce the number of operations required.

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

llvm-svn: 276432
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/test/CodeGen/AArch64/bitreverse.ll
llvm/test/CodeGen/X86/bitreverse.ll
llvm/test/CodeGen/X86/vector-bitreverse.ll