[llvm] [RISCV] Optimize pattern `(setcc (selectLT (vfirst_vl ...) , 0, EVL, ...), EVL)` (PR #90538)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 17:33:35 PDT 2024


================
@@ -13678,9 +13687,79 @@ static SDValue performSETCCCombine(SDNode *N, SelectionDAG &DAG,
                                    const RISCVSubtarget &Subtarget) {
   SDValue N0 = N->getOperand(0);
   SDValue N1 = N->getOperand(1);
+  ISD::CondCode Cond = cast<CondCodeSDNode>(N->getOperand(2))->get();
   EVT VT = N->getValueType(0);
   EVT OpVT = N0.getValueType();
+  SDLoc DL(N);
+
+  // Both rules are looking for an equality compare.
+  if (!isIntEqualitySetCC(Cond))
+    return SDValue();
+
+  // Rule 1
+  using namespace SDPatternMatch;
+  auto matchSelectCC = [](SDValue Op, SDValue VLCandidate, bool Inverse,
+                          SDValue &Select) -> bool {
+    SDValue VFirst, CC;
+    // FIXME: These pattern will fail to match if VFIRST_VL is coming from
+    // a llvm.vp.cttz.elts that doesn't return XLen type. Due to non-trivial
+    // number of sext(_inreg) and zext interleaving between the nodes.
+    // That said, this is not really problem as long as we always generate the
+    // said intrinsics with XLen return type.
----------------
mshockwave wrote:

Fixed. Now it recognizes vp.cttz.elts with non-XLen return type.

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


More information about the llvm-commits mailing list