[llvm] [InstCombine] Missed fold: umax(x, C) > ~x -> x < 0 (PR #189396)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 07:42:47 PDT 2026
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/InstCombineCompares.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/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index e029b845d..9ce7a483c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -7785,22 +7785,22 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
if (Instruction *Res = foldICmpWithZero(I))
return Res;
- Value* X;
+ Value *X;
const APInt *C;
if (I.getPredicate() == ICmpInst::ICMP_UGT &&
- match(Op0, m_UMax(m_Value(X), m_APInt(C))) &&
- match(Op1, m_Not(m_Specific(X)))) {
+ match(Op0, m_UMax(m_Value(X), m_APInt(C))) &&
+ match(Op1, m_Not(m_Specific(X)))) {
if (C->isNonNegative()) {
return new ICmpInst(ICmpInst::ICMP_SLT, X,
- Constant::getNullValue(X->getType()));
+ Constant::getNullValue(X->getType()));
}
return new ICmpInst(ICmpInst::ICMP_UGT, X,
- ConstantInt::get(X->getType(), ~*C));
+ ConstantInt::get(X->getType(), ~*C));
}
if (I.getPredicate() == ICmpInst::ICMP_ULT &&
- match(Op0, m_UMax(m_Value(X), m_APInt(C))) &&
- match(Op1, m_Not(m_Specific(X)))) {
+ match(Op0, m_UMax(m_Value(X), m_APInt(C))) &&
+ match(Op1, m_Not(m_Specific(X)))) {
if (C->isNonNegative()) {
return new ICmpInst(ICmpInst::ICMP_SGT, X,
Constant::getAllOnesValue(X->getType()));
``````````
</details>
https://github.com/llvm/llvm-project/pull/189396
More information about the llvm-commits
mailing list