From 9028f0556d24266cc76996319735531ddf2b71b1 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 24 Jan 2017 02:10:15 +0000 Subject: [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 --- llvm/lib/Support/APInt.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index fb8b45166a4..bc3e4b2666b 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -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 { -- cgit v1.2.3