[llvm] [Instcombine]: Folds`llvm.ucmp` and `llvm.scmp` (PR #168505)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 29 09:48:19 PST 2025


================
@@ -4461,6 +4461,23 @@ static Value *simplifyWithOpsReplaced(Value *V,
         return Absorber;
     }
 
+    if (auto *II = dyn_cast<IntrinsicInst>(I)) {
+      // `x == y ? 0 : ucmp(x, y)` where under the replacement y -> x,
+      // `ucmp(x, x)` becomes `0`.
+      if (NewOps[0] == NewOps[1] && (II->getIntrinsicID() == Intrinsic::scmp ||
+                                     II->getIntrinsicID() == Intrinsic::ucmp)) {
+        if (II->hasPoisonGeneratingAnnotations()) {
+          if (!DropFlags)
+            return nullptr;
+          else
+            DropFlags->push_back(II);
----------------
nikic wrote:

```suggestion
          DropFlags->push_back(II);
```
Avoid else after return.

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


More information about the llvm-commits mailing list