[PATCH] D30265: [APInt] Add APInt::setBits() method to set all bits in range
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 22 11:56:26 PST 2017
RKSimon created this revision.
The current pattern for setting bits in range is typically:
Mask |= APInt::getBitsSet(MaskSizeInBits, LoPos, HiPos);
Which can be particularly slow for large APInts (MaskSizeInBits > 64) as they require the allocation memory for the temporary variable.
This is one of the key compile time issues identified in PR32037.
This patch adds the APInt::setBits() helper method which avoids the temporary memory allocation completely, this first implementation uses setBit() internally instead but already significantly reduces the regression in PR32037 (~10% drop). Additional optimization may be possible.
I investigated whether there is need for APInt::clearBits() and APInt::flipBits() equivalents but haven't seen these patterns to be particularly common.
Repository:
rL LLVM
https://reviews.llvm.org/D30265
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: D30265.89395.patch
Type: text/x-patch
Size: 5880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170222/727d4063/attachment.bin>
More information about the llvm-commits
mailing list