summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-03-20 01:29:52 +0000
committerCraig Topper <craig.topper@gmail.com>2017-03-20 01:29:52 +0000
commit0085ffb940848c6c354a935ed88f6e27c97a88dd (patch)
tree2b5130667ee9be7baf3bced6140682953dcd7b80 /llvm/lib/Support/APInt.cpp
parentcbf04d95e6295cc35d85490fb03f7c83e9180dc5 (diff)
downloadbcm5719-llvm-0085ffb940848c6c354a935ed88f6e27c97a88dd.tar.gz
bcm5719-llvm-0085ffb940848c6c354a935ed88f6e27c97a88dd.zip
[APInt] Don't initialize VAL to 0 in APInt constructors. Push it down to the initSlowCase and other init methods.
I'm not sure if zeroing VAL before writing pVal is really necessary, but at least one other place did it in code. But by taking the store out of line, this reduces the opt binary by about 20k on my local x86-64 build. llvm-svn: 298233
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index d65dffec8c0..58fa2f53690 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -76,6 +76,7 @@ inline static unsigned getDigit(char cdigit, uint8_t radix) {
void APInt::initSlowCase(uint64_t val, bool isSigned) {
+ VAL = 0;
pVal = getClearedMemory(getNumWords());
pVal[0] = val;
if (isSigned && int64_t(val) < 0)
@@ -85,6 +86,7 @@ void APInt::initSlowCase(uint64_t val, bool isSigned) {
}
void APInt::initSlowCase(const APInt& that) {
+ VAL = 0;
pVal = getMemory(getNumWords());
memcpy(pVal, that.pVal, getNumWords() * APINT_WORD_SIZE);
}
@@ -96,6 +98,7 @@ void APInt::initFromArray(ArrayRef<uint64_t> bigVal) {
VAL = bigVal[0];
else {
// Get memory, cleared to 0
+ VAL = 0;
pVal = getClearedMemory(getNumWords());
// Calculate the number of words to copy
unsigned words = std::min<unsigned>(bigVal.size(), getNumWords());
@@ -107,12 +110,12 @@ void APInt::initFromArray(ArrayRef<uint64_t> bigVal) {
}
APInt::APInt(unsigned numBits, ArrayRef<uint64_t> bigVal)
- : BitWidth(numBits), VAL(0) {
+ : BitWidth(numBits) {
initFromArray(bigVal);
}
APInt::APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[])
- : BitWidth(numBits), VAL(0) {
+ : BitWidth(numBits) {
initFromArray(makeArrayRef(bigVal, numWords));
}
OpenPOWER on IntegriCloud