mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[APInt] Remove calls to clearUnusedBits from XorSlowCase and operator^=
Summary: 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 Reviewers: majnemer, MatzeB, chandlerc, bkramer Reviewed By: MatzeB Subscribers: chfast, llvm-commits Differential Revision: https://reviews.llvm.org/D28986 llvm-svn: 292873
This commit is contained in:
parent
e929d35db5
commit
dc69bac218
@ -440,13 +440,12 @@ APInt& APInt::operator^=(const APInt& RHS) {
|
||||
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 {
|
||||
@ -471,10 +470,7 @@ APInt APInt::XorSlowCase(const APInt& RHS) const {
|
||||
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 {
|
||||
|
@ -158,6 +158,36 @@ TEST(APIntTest, i1) {
|
||||
EXPECT_EQ(two, one - neg_one);
|
||||
EXPECT_EQ(zero, one - one);
|
||||
|
||||
// And
|
||||
EXPECT_EQ(zero, zero & zero);
|
||||
EXPECT_EQ(zero, one & zero);
|
||||
EXPECT_EQ(zero, zero & one);
|
||||
EXPECT_EQ(one, one & one);
|
||||
EXPECT_EQ(zero, zero & zero);
|
||||
EXPECT_EQ(zero, neg_one & zero);
|
||||
EXPECT_EQ(zero, zero & neg_one);
|
||||
EXPECT_EQ(neg_one, neg_one & neg_one);
|
||||
|
||||
// Or
|
||||
EXPECT_EQ(zero, zero | zero);
|
||||
EXPECT_EQ(one, one | zero);
|
||||
EXPECT_EQ(one, zero | one);
|
||||
EXPECT_EQ(one, one | one);
|
||||
EXPECT_EQ(zero, zero | zero);
|
||||
EXPECT_EQ(neg_one, neg_one | zero);
|
||||
EXPECT_EQ(neg_one, zero | neg_one);
|
||||
EXPECT_EQ(neg_one, neg_one | neg_one);
|
||||
|
||||
// Xor
|
||||
EXPECT_EQ(zero, zero ^ zero);
|
||||
EXPECT_EQ(one, one ^ zero);
|
||||
EXPECT_EQ(one, zero ^ one);
|
||||
EXPECT_EQ(zero, one ^ one);
|
||||
EXPECT_EQ(zero, zero ^ zero);
|
||||
EXPECT_EQ(neg_one, neg_one ^ zero);
|
||||
EXPECT_EQ(neg_one, zero ^ neg_one);
|
||||
EXPECT_EQ(zero, neg_one ^ neg_one);
|
||||
|
||||
// Shifts.
|
||||
EXPECT_EQ(zero, one << one);
|
||||
EXPECT_EQ(one, one << zero);
|
||||
|
Loading…
x
Reference in New Issue
Block a user