[PATCH] D19978: [SelectionDAG] Attempt to split BITREVERSE vector legalization into BSWAP and BITREVERSE stages

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 08:33:39 PDT 2016


RKSimon created this revision.
RKSimon added reviewers: jmolloy, spatel, andreadb.
RKSimon added a subscriber: llvm-commits.
RKSimon set the repository for this revision to rL LLVM.
Herald added a subscriber: aemerson.

For BITREVERSE, bit shifting/masking every bit in a vector element is a very lengthy procedure.

If the input vector type is a whole multiple of bytes wide then we can split this into a BSWAP shuffle stage (to reverse at the byte level) and then a BITREVERSE stage applied to each byte. Most vector capable targets can efficiently BSWAP using shuffles resulting in a considerable reduction in instructions.

With this patch targets would only need to implement a target specific vXi8 BITREVERSE implementation to efficiently reverse most legal vector types (I'm intending to add a SSSE3 PSHUFB implementation as an example).

James - This has definitely been tested on AARCH64 this time, at the moment I've just added a token rev32 CHECK but I can expand this to a more thorough set of CHECKs if you'd prefer? I know the x86 approach of scripted 'full' CHECKs isn't always popular ;-)

Repository:
  rL LLVM

http://reviews.llvm.org/D19978

Files:
  lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
  test/CodeGen/AArch64/bitreverse.ll
  test/CodeGen/X86/vector-bitreverse.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19978.56295.patch
Type: text/x-patch
Size: 181682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160505/30d7f79d/attachment-0001.bin>


More information about the llvm-commits mailing list