[PATCH] D33572: [PPC] Implement fast bit reverse in PPCDAGToDAGISel

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 15:36:38 PDT 2017


Carrot created this revision.
Herald added a subscriber: nemanjai.

This patch fixes pr33093.

Current PPCDAGToDAGISel doesn't handle bit reverse efficiently, it generates bit by bit moves for it, even if we give it the following fast algorithm.

unsigned int ReverseBits(unsigned int n) {

  n = ((n >> 1) & 0x55555555) | ((n & 0x55555555) << 1);
  n = ((n >> 2) & 0x33333333) | ((n & 0x33333333) << 2);
  n = ((n >> 4) & 0x0F0F0F0F) | ((n & 0x0F0F0F0F) << 4);
  return ((n & 0xff000000u) >> 24) | ((n & 0x00ff0000u) >> 8) | ((n & 0x0000ff00u) << 8) | ((n & 0x000000ffu) << 24);

}

This patch recognizes bit reverse in BitPermutationSelector, and generates the fast code shown above.


https://reviews.llvm.org/D33572

Files:
  lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  test/CodeGen/PowerPC/pr33093.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33572.100314.patch
Type: text/x-patch
Size: 15696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170525/70b87859/attachment.bin>


More information about the llvm-commits mailing list