[llvm] [X86][ISel] Improve VPTERNLOG matching for negated logic trees (PR #164863)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 22:04:42 PDT 2025


================
@@ -4740,6 +4737,34 @@ bool X86DAGToDAGISel::tryVPTERNLOG(SDNode *N) {
     return SDValue();
   };
 
+  // Identify and (optionally) peel an outer NOT that wraps a pure logic tree
+  auto tryPeelOuterNotWrappingLogic = [&](SDNode *Op) {
+    if (Op->getOpcode() == ISD::XOR && Op->hasOneUse() &&
+        ISD::isBuildVectorAllOnes(Op->getOperand(1).getNode())) {
+      SDValue InnerOp = Op->getOperand(0);
+
+      if (!getFoldableLogicOp(InnerOp)) {
+        return SDValue();
+      }
----------------
phoebewang wrote:

```suggestion
      if (!getFoldableLogicOp(InnerOp))
        return SDValue();
```

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


More information about the llvm-commits mailing list