[llvm] 1eaf7ba - APInt.h - return directly from clearUnusedBits in single word cases. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 05:25:48 PDT 2020
Author: Simon Pilgrim
Date: 2020-09-09T13:22:57+01:00
New Revision: 1eaf7babf2dcc3ab8fb429171c991556ffa98291
URL: https://github.com/llvm/llvm-project/commit/1eaf7babf2dcc3ab8fb429171c991556ffa98291
DIFF: https://github.com/llvm/llvm-project/commit/1eaf7babf2dcc3ab8fb429171c991556ffa98291.diff
LOG: APInt.h - return directly from clearUnusedBits in single word cases. NFCI.
Consistently use the same pattern of returning *this from the clearUnusedBits() call to allow us to early out from the isSingleWord() path and avoid an else statement.
Added:
Modified:
llvm/include/llvm/ADT/APInt.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 5e4206732f4d..fdc0850d21eb 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -794,11 +794,10 @@ class LLVM_NODISCARD APInt {
APInt &operator=(uint64_t RHS) {
if (isSingleWord()) {
U.VAL = RHS;
- clearUnusedBits();
- } else {
- U.pVal[0] = RHS;
- memset(U.pVal+1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
+ return clearUnusedBits();
}
+ U.pVal[0] = RHS;
+ memset(U.pVal + 1, 0, (getNumWords() - 1) * APINT_WORD_SIZE);
return *this;
}
@@ -855,10 +854,9 @@ class LLVM_NODISCARD APInt {
APInt &operator|=(uint64_t RHS) {
if (isSingleWord()) {
U.VAL |= RHS;
- clearUnusedBits();
- } else {
- U.pVal[0] |= RHS;
+ return clearUnusedBits();
}
+ U.pVal[0] |= RHS;
return *this;
}
@@ -885,10 +883,9 @@ class LLVM_NODISCARD APInt {
APInt &operator^=(uint64_t RHS) {
if (isSingleWord()) {
U.VAL ^= RHS;
- clearUnusedBits();
- } else {
- U.pVal[0] ^= RHS;
+ return clearUnusedBits();
}
+ U.pVal[0] ^= RHS;
return *this;
}
More information about the llvm-commits
mailing list