[llvm] [InstCombine] Fold select(X >s 0, 0, -X) | smax(X, 0) to abs(X) (PR #165200)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 27 19:03:22 PDT 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/InstCombineAndOrXor.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/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index a0cd19195..ddb4e89a2 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -4002,7 +4002,8 @@ static Value *FoldOrOfSelectSmaxToAbs(BinaryOperator &I,
                                       InstCombiner::BuilderTy &Builder) {
   CmpPredicate Pred;
   Value *X;
-  if (match(&I, m_c_Or(m_Select(m_SpecificICmp(ICmpInst::ICMP_SGT, m_Value(X), m_ZeroInt()),
+  if (match(&I, m_c_Or(m_Select(m_SpecificICmp(ICmpInst::ICMP_SGT, m_Value(X),
+                                               m_ZeroInt()),
                                 m_ZeroInt(), m_Sub(m_ZeroInt(), m_Deferred(X))),
                        m_OneUse(m_Intrinsic<Intrinsic::smax>(m_Deferred(X),
                                                              m_ZeroInt())))))

``````````

</details>


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


More information about the llvm-commits mailing list