OSDN Git Service

Don't allocate unnecessarily in APInt::operator[+-]. NFC.
authorPete Cooper <peter_cooper@apple.com>
Fri, 27 May 2016 03:42:17 +0000 (03:42 +0000)
committerPete Cooper <peter_cooper@apple.com>
Fri, 27 May 2016 03:42:17 +0000 (03:42 +0000)
commit1544fa23686388696e1e8de4e1f0fda3808609f2
tree7b9cf38e5f024c3082aff60298488cff2f210459
parent70172d9997f9c695009294646ca16d5bf238c16b
Don't allocate unnecessarily in APInt::operator[+-].  NFC.

APInt::operator+(uint64_t) just forwarded to operator+(const APInt&).

Constructing the APInt for the RHS takes an allocation which isn't
required.  Also, for APInt's in the slow path, operator+ would
call add() internally which iterates over both arrays of values.  Instead
we can use add_1 and sub_1 which only iterate while there is something to do.

Using the memory for 'opt -O2 verify-uselistorder.lto.opt.bc -o opt.bc'
(see r236629 for details), this reduces the number of allocations from
23.9M to 22.7M.

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