forked from OSchip/llvm-project
[APInt] Move the 'return *this' from the slow cases of assignment operators inline. We should let the compiler see that the fast/slow cases both return *this.
I don't think we chain assignments together very often so this shouldn't matter much. llvm-svn: 300715
This commit is contained in:
parent
a3c297dba4
commit
c67fe57e1e
|
@ -195,7 +195,7 @@ private:
|
|||
void lshrSlowCase(unsigned ShiftAmt);
|
||||
|
||||
/// out-of-line slow case for operator=
|
||||
APInt &AssignSlowCase(const APInt &RHS);
|
||||
void AssignSlowCase(const APInt &RHS);
|
||||
|
||||
/// out-of-line slow case for operator==
|
||||
bool EqualSlowCase(const APInt &RHS) const LLVM_READONLY;
|
||||
|
@ -219,13 +219,13 @@ private:
|
|||
void flipAllBitsSlowCase();
|
||||
|
||||
/// out-of-line slow case for operator&=.
|
||||
APInt& AndAssignSlowCase(const APInt& RHS);
|
||||
void AndAssignSlowCase(const APInt& RHS);
|
||||
|
||||
/// out-of-line slow case for operator|=.
|
||||
APInt& OrAssignSlowCase(const APInt& RHS);
|
||||
void OrAssignSlowCase(const APInt& RHS);
|
||||
|
||||
/// out-of-line slow case for operator^=.
|
||||
APInt& XorAssignSlowCase(const APInt& RHS);
|
||||
void XorAssignSlowCase(const APInt& RHS);
|
||||
|
||||
public:
|
||||
/// \name Constructors
|
||||
|
@ -691,7 +691,8 @@ public:
|
|||
return clearUnusedBits();
|
||||
}
|
||||
|
||||
return AssignSlowCase(RHS);
|
||||
AssignSlowCase(RHS);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// @brief Move assignment operator.
|
||||
|
@ -736,11 +737,11 @@ public:
|
|||
/// \returns *this after ANDing with RHS.
|
||||
APInt &operator&=(const APInt &RHS) {
|
||||
assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
|
||||
if (isSingleWord()) {
|
||||
if (isSingleWord())
|
||||
VAL &= RHS.VAL;
|
||||
return *this;
|
||||
}
|
||||
return AndAssignSlowCase(RHS);
|
||||
else
|
||||
AndAssignSlowCase(RHS);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// \brief Bitwise AND assignment operator.
|
||||
|
@ -766,11 +767,11 @@ public:
|
|||
/// \returns *this after ORing with RHS.
|
||||
APInt &operator|=(const APInt &RHS) {
|
||||
assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
|
||||
if (isSingleWord()) {
|
||||
if (isSingleWord())
|
||||
VAL |= RHS.VAL;
|
||||
return *this;
|
||||
}
|
||||
return OrAssignSlowCase(RHS);
|
||||
else
|
||||
OrAssignSlowCase(RHS);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// \brief Bitwise OR assignment operator.
|
||||
|
@ -796,11 +797,11 @@ public:
|
|||
/// \returns *this after XORing with RHS.
|
||||
APInt &operator^=(const APInt &RHS) {
|
||||
assert(BitWidth == RHS.BitWidth && "Bit widths must be the same");
|
||||
if (isSingleWord()) {
|
||||
if (isSingleWord())
|
||||
VAL ^= RHS.VAL;
|
||||
return *this;
|
||||
}
|
||||
return XorAssignSlowCase(RHS);
|
||||
else
|
||||
XorAssignSlowCase(RHS);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// \brief Bitwise XOR assignment operator.
|
||||
|
|
|
@ -125,16 +125,16 @@ APInt::APInt(unsigned numbits, StringRef Str, uint8_t radix)
|
|||
fromString(numbits, Str, radix);
|
||||
}
|
||||
|
||||
APInt& APInt::AssignSlowCase(const APInt& RHS) {
|
||||
void APInt::AssignSlowCase(const APInt& RHS) {
|
||||
// Don't do anything for X = X
|
||||
if (this == &RHS)
|
||||
return *this;
|
||||
return;
|
||||
|
||||
if (BitWidth == RHS.getBitWidth()) {
|
||||
// assume same bit-width single-word case is already handled
|
||||
assert(!isSingleWord());
|
||||
memcpy(pVal, RHS.pVal, getNumWords() * APINT_WORD_SIZE);
|
||||
return *this;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isSingleWord()) {
|
||||
|
@ -154,7 +154,7 @@ APInt& APInt::AssignSlowCase(const APInt& RHS) {
|
|||
memcpy(pVal, RHS.pVal, RHS.getNumWords() * APINT_WORD_SIZE);
|
||||
}
|
||||
BitWidth = RHS.BitWidth;
|
||||
return clearUnusedBits();
|
||||
clearUnusedBits();
|
||||
}
|
||||
|
||||
/// This method 'profiles' an APInt for use with FoldingSet.
|
||||
|
@ -339,19 +339,16 @@ APInt& APInt::operator*=(const APInt& RHS) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
APInt& APInt::AndAssignSlowCase(const APInt& RHS) {
|
||||
void APInt::AndAssignSlowCase(const APInt& RHS) {
|
||||
tcAnd(pVal, RHS.pVal, getNumWords());
|
||||
return *this;
|
||||
}
|
||||
|
||||
APInt& APInt::OrAssignSlowCase(const APInt& RHS) {
|
||||
void APInt::OrAssignSlowCase(const APInt& RHS) {
|
||||
tcOr(pVal, RHS.pVal, getNumWords());
|
||||
return *this;
|
||||
}
|
||||
|
||||
APInt& APInt::XorAssignSlowCase(const APInt& RHS) {
|
||||
void APInt::XorAssignSlowCase(const APInt& RHS) {
|
||||
tcXor(pVal, RHS.pVal, getNumWords());
|
||||
return *this;
|
||||
}
|
||||
|
||||
APInt APInt::operator*(const APInt& RHS) const {
|
||||
|
|
Loading…
Reference in New Issue