aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-05-08 06:34:41 +0000
committerCraig Topper <craig.topper@gmail.com>2017-05-08 06:34:41 +0000
commitc96a84d813925c30f516030c259fac0b4375e6e3 (patch)
tree37de9ed2cb5a049ba912cbf4fda67b72229158bb /llvm/lib/Support/APInt.cpp
parent0cbab7cc7ab328b26bc26356b8fd0fd0f3816d19 (diff)
downloadllvm-c96a84d813925c30f516030c259fac0b4375e6e3.zip
llvm-c96a84d813925c30f516030c259fac0b4375e6e3.tar.gz
llvm-c96a84d813925c30f516030c259fac0b4375e6e3.tar.bz2
[APInt] Modify tcMultiplyPart's overflow detection to not depend on 'i' from the earlier loop. NFC
The value of 'i' is always the smaller of DstParts and SrcParts so we can just use that fact to write all the code in terms of SrcParts and DstParts. llvm-svn: 302408
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 4a136f7..caa0691 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -2254,8 +2254,7 @@ int APInt::tcMultiplyPart(WordType *dst, const WordType *src,
/* N loops; minimum of dstParts and srcParts. */
unsigned n = std::min(dstParts, srcParts);
- unsigned i;
- for (i = 0; i < n; i++) {
+ for (unsigned i = 0; i < n; i++) {
WordType low, mid, high, srcPart;
/* [ LOW, HIGH ] = MULTIPLIER * SRC[i] + DST[i] + CARRY.
@@ -2306,10 +2305,10 @@ int APInt::tcMultiplyPart(WordType *dst, const WordType *src,
carry = high;
}
- if (i < dstParts) {
+ if (srcParts < dstParts) {
/* Full multiplication, there is no overflow. */
- assert(i + 1 == dstParts);
- dst[i] = carry;
+ assert(srcParts + 1 == dstParts);
+ dst[srcParts] = carry;
return 0;
}
@@ -2321,7 +2320,7 @@ int APInt::tcMultiplyPart(WordType *dst, const WordType *src,
non-zero. This is true if any remaining src parts are non-zero
and the multiplier is non-zero. */
if (multiplier)
- for (; i < srcParts; i++)
+ for (unsigned i = dstParts; i < srcParts; i++)
if (src[i])
return 1;