[llvm] [InstCombine] Add missing patterns for scmp and ucmp (PR #149225)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 18 10:08:55 PDT 2025


================
@@ -3849,6 +3853,45 @@ Instruction *InstCombinerImpl::foldSelectToCmp(SelectInst &SI) {
     }
   }
 
+  // Special cases with constants: x == C ? 0 : (x > C-1 ? 1 : -1)
+  if (Pred == ICmpInst::ICMP_EQ && match(TV, m_Zero())) {
+    Value *X;
+    const APInt *C;
+    if (match(LHS, m_Value(X)) && match(RHS, m_APInt(C))) {
----------------
dtcxzyw wrote:

```suggestion
    if (match(RHS, m_APInt(C))) {
```
Use LHS directly

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


More information about the llvm-commits mailing list