[llvm] [AArch64][SME] Introduce CHECK_MATCHING_VL pseudo for streaming transitions (PR #157510)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 07:14:31 PDT 2025


================
@@ -9147,7 +9199,38 @@ SDValue AArch64TargetLowering::changeStreamingMode(SelectionDAG &DAG, SDLoc DL,
   if (InGlue)
     Ops.push_back(InGlue);
 
-  return DAG.getNode(Opcode, DL, DAG.getVTList(MVT::Other, MVT::Glue), Ops);
+  if (!InsertVectorLengthCheck)
+    return DAG.getNode(Opcode, DL, DAG.getVTList(MVT::Other, MVT::Glue), Ops);
+
+  auto GetCheckVL = [&](SDValue Chain, SDValue InGlue = SDValue()) -> SDValue {
+    SmallVector<SDValue, 2> Ops = {Chain};
+    if (InGlue)
+      Ops.push_back(InGlue);
+    return DAG.getNode(AArch64ISD::CHECK_MATCHING_VL, DL,
+                       DAG.getVTList(MVT::Other, MVT::Glue), Ops);
+  };
+
+  // Non-streaming -> Streaming
+  if (Enable) {
+    SDValue CheckVL = GetCheckVL(Chain, InGlue);
+
+    // Replace chain
+    Ops[0] = CheckVL.getValue(0);
----------------
sdesmalen-arm wrote:

I find the fiddling with `Ops` a bit confusing. I think it would be a bit simpler if this would do something like:

```
if (InsertVectorLengthCheck && Enable) {
  // Non-streaming -> streaming
  SDValue Check = GetCheckVL(..);
  Chain = Check.getValue(0);
  Glue = Check.getValue(1);
}

// <...code here that does set up of `Ops` for the smstart/smstop...>
SDValue SMChange = DAG.getNode(...);

if (!InsertVectorLengthCheck || Enable)
  return SMChange;

// Streaming -> non-streaming
return GetCheckVL(SMChange.getValue(0), SMChange.getValue(1));
````

where it's obvious from the order of emitting the nodes, where the check will be inserted.

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


More information about the llvm-commits mailing list