]> granicus.if.org Git - llvm/commit
[APInt] Add setLowBits/setHighBits methods to APInt.
authorCraig Topper <craig.topper@gmail.com>
Tue, 7 Mar 2017 01:56:01 +0000 (01:56 +0000)
committerCraig Topper <craig.topper@gmail.com>
Tue, 7 Mar 2017 01:56:01 +0000 (01:56 +0000)
commit73046581a3eca1a6b91ed2d43d4b37a0b01ca2ed
tree4fbfa8ef81e049194d7409f5ab4544a5c933073c
parent66193c91b4980bd612d0d4d14d24f9a3e8cade23
[APInt] Add setLowBits/setHighBits methods to APInt.

Summary:
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.

Reviewers: majnemer, MatzeB, davide, RKSimon, hans

Reviewed By: hans

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D30525

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297111 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/APInt.h
lib/Support/APInt.cpp
unittests/ADT/APIntTest.cpp