[PATCH] D30336: [APInt] Add APInt::extractBits() method to extract APInt subrange

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 05:52:48 PST 2017


RKSimon created this revision.

The current pattern for extract bits in range is typically:

Mask.lshr(BitOffset).trunc(SubSizeInBits);

Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation of memory for the temporary variable.

This is another of the compile time issues identified in PR32037 (see also https://reviews.llvm.org/D30265).

This patch adds the APInt::extractBits() helper method which avoids the temporary memory allocation.


Repository:
  rL LLVM

https://reviews.llvm.org/D30336

Files:
  include/llvm/ADT/APInt.h
  lib/Support/APInt.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Target/X86/X86ShuffleDecodeConstantPool.cpp
  unittests/ADT/APIntTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30336.89656.patch
Type: text/x-patch
Size: 5221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170224/7e2704a4/attachment.bin>


More information about the llvm-commits mailing list