[PATCH] D28986: [APInt] Remove calls to clearUnusedBits from XorSlowCase and operator^=
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 22 00:34:38 PST 2017
craig.topper created this revision.
There's a comment in XorSlowCase that says "0^0==1" which isn't true. 0 xored with 0 is still 0. So I don't think we need to clear any unused bits here.
Now there is no difference between XorSlowCase and AndSlowCase/OrSlowCase other than the operation being performed
https://reviews.llvm.org/D28986
Files:
lib/Support/APInt.cpp
Index: lib/Support/APInt.cpp
===================================================================
--- lib/Support/APInt.cpp
+++ lib/Support/APInt.cpp
@@ -440,13 +440,12 @@
assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
if (isSingleWord()) {
VAL ^= RHS.VAL;
- this->clearUnusedBits();
return *this;
}
unsigned numWords = getNumWords();
for (unsigned i = 0; i < numWords; ++i)
pVal[i] ^= RHS.pVal[i];
- return clearUnusedBits();
+ return *this;
}
APInt APInt::AndSlowCase(const APInt& RHS) const {
@@ -470,11 +469,7 @@
uint64_t *val = getMemory(numWords);
for (unsigned i = 0; i < numWords; ++i)
val[i] = pVal[i] ^ RHS.pVal[i];
-
- APInt Result(val, getBitWidth());
- // 0^0==1 so clear the high bits in case they got set.
- Result.clearUnusedBits();
- return Result;
+ return APInt(val, getBitWidth());
}
APInt APInt::operator*(const APInt& RHS) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28986.85273.patch
Type: text/x-patch
Size: 931 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170122/ee852458/attachment.bin>
More information about the llvm-commits
mailing list