[llvm] [InstCombine] Fold (sub nsw X, umin(X, C)) s< C2 to (X s< C + C2) (PR #170422)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 21:46:45 PST 2025


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/Transforms/InstCombine/InstCombineAddSub.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/Transforms/InstCombine/InstCombineAddSub.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
index df096e7b8..6a0c75f76 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -2864,8 +2864,8 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
     // 2. C2 > 0: Range [C, C+C2) must imply extension.
     // 3. No Signed Overflow: Merged upper bound (C + C2) must be safe.
     const APInt *C;
-    if (I.hasOneUse() && I.hasNoSignedWrap() &&
-        match(X, m_APInt(C)) && C->isNonNegative()) {
+    if (I.hasOneUse() && I.hasNoSignedWrap() && match(X, m_APInt(C)) &&
+        C->isNonNegative()) {
       const APInt *C2;
       CmpPredicate Pred;
       Instruction *MustICmp = cast<Instruction>(I.user_back());

``````````

</details>


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


More information about the llvm-commits mailing list