[llvm] [InstCombine] Fold (add (add A, 1), (sext (icmp ne A, 0))) to call umax(A, 1) (PR #122491)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 21:10:22 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 6b12272353b45def33bf5814cdf9e8587f32d40e 13bc4b476f75dbecc9609debd2e7a736d549b2d3 --extensions cpp -- llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
``````````

</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 83e1d3bdf9..3999a09a4e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1778,9 +1778,10 @@ Instruction *InstCombinerImpl::visitAdd(BinaryOperator &I) {
   // (add (add A, 1), (sext (icmp ne A, 0))) => call umax(A, 1)
   if (match(LHS, m_OneUse(m_Add(m_Value(A), m_One()))) &&
       match(RHS, m_OneUse(m_SExt(m_OneUse(m_SpecificICmp(
-        ICmpInst::ICMP_NE, m_Deferred(A), m_ZeroInt())))))) {
+                     ICmpInst::ICMP_NE, m_Deferred(A), m_ZeroInt())))))) {
     Value *OneConst = ConstantInt::get(A->getType(), 1);
-    Value *UMax = Builder.CreateIntrinsic(Intrinsic::umax, A->getType(), {A, OneConst});
+    Value *UMax =
+        Builder.CreateIntrinsic(Intrinsic::umax, A->getType(), {A, OneConst});
     return replaceInstUsesWith(I, UMax);
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list