[llvm] [RISCV] Fold vmnot.m of an integer compare into the compare (PR #222553)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 22:17:59 PDT 2026


================
@@ -19560,6 +19253,29 @@ static SDValue performORCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
   return combineSelectAndUseCommutative(N, DAG, /*AllOnes*/ false, Subtarget);
 }
 
+// Fold (vmxor_vl (setcc_vl a, b, cc), vmset_vl) -> (setcc_vl a, b, !cc) for
+// integer compares. The NOT also flips the masked-off lanes, which the inverted
+// compare copies unchanged from the passthru. So the passthru must be undef,
+// but any mask is fine.
+static SDValue combineVMNOTOfSetCC(SDNode *N, SelectionDAG &DAG) {
+  SDValue Cmp = N->getOperand(0);
+  if (Cmp.getOpcode() == RISCVISD::VMSET_VL)
+    Cmp = N->getOperand(1);
+  else if (N->getOperand(1).getOpcode() != RISCVISD::VMSET_VL)
+    return SDValue();
----------------
wangpc-pp wrote:

```suggestion
  if (Cmp.getOpcode() != RISCVISD::VMSET_VL && N->getOperand(1).getOpcode() != RISCVISD::VMSET_VL)
    return SDValue();

  if (Cmp.getOpcode() == RISCVISD::VMSET_VL)
    Cmp = N->getOperand(1);
```

Something like this :-)

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


More information about the llvm-commits mailing list