[PATCH] D30525: [APInt] Add setLowBits/setHighBits methods to APInt.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 1 23:10:16 PST 2017


craig.topper created this revision.

There are quite a few places in the code base that do something like the following to set the high or low bits in an APInt.

KnownZero |= APInt::getHighBitsSet(BitWidth, BitWidth - 1);

For BitWidths larger than 64 this creates a short lived APInt with malloced storage. I think it might even call malloc twice. Its better to just provide methods that can set the necessary bits without the temporary APInt.

I'll update usages that benefit in a separate patch.


https://reviews.llvm.org/D30525

Files:
  include/llvm/ADT/APInt.h
  lib/Support/APInt.cpp
  unittests/ADT/APIntTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30525.90282.patch
Type: text/x-patch
Size: 7264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170302/640bf78d/attachment.bin>


More information about the llvm-commits mailing list