[llvm] [InstCombine] Fold (sub (xor X, (sext C)), (sext C)) => (select C (neg X), X) (PR #79417)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 21:56:52 PST 2024


================
@@ -2448,6 +2448,16 @@ Instruction *InstCombinerImpl::visitSub(BinaryOperator &I) {
     }
   }
 
+  {
+    // (sub (xor X, (sext C)), (sext C)) => (select C (neg X), X)
+    Value *C0, *C1, *X;
+    if (match(Op0, m_Xor(m_Value(X), m_SExt(m_Value(C0)))) &&
+        (C0->getType()->getScalarSizeInBits() == 1) &&
+        match(Op1, m_SExt(m_Value(C1))) && (C0 == C1)) {
----------------
dtcxzyw wrote:

```suggestion
        match(Op1, m_SExt(m_Specific(C0)))) {
```

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


More information about the llvm-commits mailing list