[llvm] [RISCV] Break the (czero_eqz x, (setne x, 0)) -> x combine into 2 combines. (PR #90428)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 28 20:52:38 PDT 2024


================
@@ -16165,28 +16165,36 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
     return performSELECTCombine(N, DAG, Subtarget);
   case RISCVISD::CZERO_EQZ:
   case RISCVISD::CZERO_NEZ: {
-    SDValue LHS = N->getOperand(0);
-    SDValue RHS = N->getOperand(1);
-    // czero_eq X, (xor Y, 1) -> czero_ne X, Y if Y is 0 or 1.
-    // czero_ne X, (xor Y, 1) -> czero_eq X, Y if Y is 0 or 1.
-    if (RHS.getOpcode() == ISD::XOR && isOneConstant(RHS.getOperand(1))) {
-      SDValue Cond = RHS.getOperand(0);
+    SDValue Val = N->getOperand(0);
+    SDValue Cond = N->getOperand(1);
+
+    unsigned Opc = N->getOpcode();
+
+    // czero_eqz x, x -> x
+    if (Opc && Val == Cond)
----------------
dtcxzyw wrote:

```suggestion
    if (Opc == RISCVISD::CZERO_EQZ && Val == Cond)
```

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


More information about the llvm-commits mailing list