[llvm] [Support][APint] Optimize fallback case in APInt::reverseBits (PR #189291)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 08:09:38 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Support/APInt.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index b5e1a3276..df82d4da1 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -785,7 +785,7 @@ APInt APInt::reverseBits() const {
return APInt(BitWidth, llvm::reverseBits<uint16_t>(U.VAL));
case 8:
return APInt(BitWidth, llvm::reverseBits<uint8_t>(U.VAL));
- case 1: // fallthrough
+ case 1: // fallthrough
case 0:
return *this;
default:
@@ -793,7 +793,8 @@ APInt APInt::reverseBits() const {
}
// Special case for all widths less than 64 and non-power-of-2
if (BitWidth < 64)
- return APInt(BitWidth, llvm::reverseBits<uint64_t>(U.VAL) >> (64 - BitWidth));
+ return APInt(BitWidth,
+ llvm::reverseBits<uint64_t>(U.VAL) >> (64 - BitWidth));
APInt Result(BitWidth, 0);
unsigned NumWords = getNumWords();
``````````
</details>
https://github.com/llvm/llvm-project/pull/189291
More information about the llvm-commits
mailing list