[llvm] [Knowbits] Make nuw and nsw support in computeForAddSub optimal (PR #83382)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 23:01:20 PST 2024


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 64422cf826354ee1d586c2484ec72d66db898e75 52e6be73ded61a61bccb7d7379f96cc13f00b70c -- llvm/include/llvm/Support/KnownBits.h llvm/lib/Analysis/ValueTracking.cpp llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp llvm/lib/Support/KnownBits.cpp llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp llvm/lib/Target/ARM/ARMISelLowering.cpp llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/unittests/Support/KnownBitsTest.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp
index b575f97094..04eb83c0e4 100644
--- a/llvm/lib/Support/KnownBits.cpp
+++ b/llvm/lib/Support/KnownBits.cpp
@@ -158,7 +158,7 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW, bool NUW,
       }
     }
     if (NUW) {
-        // (add nuw X, Y)
+      // (add nuw X, Y)
       bool OverflowMax, OverflowMin;
       APInt MaxVal = GetMaxVal(/*ForNSW*/ false, LHS, RHS, OverflowMax);
       APInt MinVal = GetMinVal(/*ForNSW*/ false, LHS, RHS, OverflowMin);
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index e0db129ae7..df22a17d4a 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -210,7 +210,6 @@ static void TestAddSubExhaustive(bool IsAdd) {
             KnownNSWAndNUW.One &= Res;
             KnownNSWAndNUW.Zero &= ~Res;
           }
-
         });
       });
 
@@ -241,7 +240,6 @@ static void TestAddSubExhaustive(bool IsAdd) {
       }
       EXPECT_TRUE(
           isCorrect(KnownNSWAndNUW, KnownNSWAndNUWComputed, {Known1, Known2}));
-
     });
   });
 }

``````````

</details>


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


More information about the llvm-commits mailing list