[llvm] [InstCombine] Simplify compare abs(X) and X. (PR #76385)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 29 04:41:24 PST 2023


================
@@ -7109,6 +7109,47 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
     }
   }
 
+  {
+    Value *X;
+    Constant *C;
+    if (match(Op0, m_OneUse(m_Intrinsic<Intrinsic::abs>(m_Value(X),
+                                                        m_Constant(C)))) &&
+        match(Op1, m_Specific(X))) {
+      auto *NullValue = Constant::getNullValue(X->getType());
+      auto *MinVal = ConstantInt::get(
----------------
dtcxzyw wrote:

```suggestion
      Value *NullValue = Constant::getNullValue(X->getType());
      Value *MinVal = ConstantInt::get(
```

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


More information about the llvm-commits mailing list