[llvm] [ConstantRange] Handle `Intrinsic::cttz` (PR #67917)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 4 08:41:32 PDT 2023


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 bde5717d4638c27614d9d4a2e53df27087a69841 a2ea2e944c591c37ca7406e10518cdc36df87915 -- llvm/include/llvm/IR/ConstantRange.h llvm/lib/IR/ConstantRange.cpp llvm/unittests/IR/ConstantRangeTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index ae82761bb453..a39dbac28f1a 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -1761,7 +1761,8 @@ static ConstantRange getUnsignedCountTrailingZerosRange(const APInt &Lower,
   // Otherwise, the maximum is BitWidth - LCPLength - 1 ({LCP, 100...}).
   return ConstantRange(
       APInt::getZero(BitWidth),
-      APInt(BitWidth, std::max(BitWidth - LCPLength - 1, Lower.countr_zero()) + 1));
+      APInt(BitWidth,
+            std::max(BitWidth - LCPLength - 1, Lower.countr_zero()) + 1));
 }
 
 ConstantRange ConstantRange::cttz(bool ZeroIsPoison) const {
@@ -1785,14 +1786,13 @@ ConstantRange ConstantRange::cttz(bool ZeroIsPoison) const {
       }
 
       // Compute the resulting range by excluding zero from Lower.
-      return getUnsignedCountTrailingZerosRange(APInt(getBitWidth(), 1), getUpper());
+      return getUnsignedCountTrailingZerosRange(APInt(getBitWidth(), 1),
+                                                getUpper());
     } else if (getUpper() == 1) {
       // Compute the resulting range by excluding zero from Upper.
-      return getUnsignedCountTrailingZerosRange(
-          getLower(), Zero);
+      return getUnsignedCountTrailingZerosRange(getLower(), Zero);
     } else {
-      ConstantRange CR1 = getUnsignedCountTrailingZerosRange(
-          getLower(), Zero);
+      ConstantRange CR1 = getUnsignedCountTrailingZerosRange(getLower(), Zero);
       ConstantRange CR2 = getUnsignedCountTrailingZerosRange(
           APInt(getBitWidth(), 1), getUpper());
       return CR1.unionWith(CR2);

``````````

</details>


https://github.com/llvm/llvm-project/pull/67917


More information about the llvm-commits mailing list