[llvm] [RISCV] Combine chained `V[SZ]EXT_VL` ops (PR #211583)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 07:31:14 PDT 2026


================
@@ -20702,6 +20702,29 @@ static SDValue performVFMADD_VLCombine(SDNode *N,
   return combineOp_VLToVWOp_VL(N, DCI, Subtarget);
 }
 
+static SDValue performVEXT_VLCombine(SDNode *N,
+                                     TargetLowering::DAGCombinerInfo &DCI,
+                                     const RISCVSubtarget &Subtarget) {
+  unsigned Opcode = N->getOpcode();
+  assert((Opcode == RISCVISD::VSEXT_VL || Opcode == RISCVISD::VZEXT_VL) &&
+         "Unexpected opcode");
+
+  SDValue Inner = N->getOperand(0);
+  SDValue Mask = N->getOperand(1);
+  SDValue VL = N->getOperand(2);
+
+  // Combine (vext_vl (vext_vl x, m, vl), m, vl) -> (vext_vl x, m, vl)
+  // where vext_vl is either vsext_vl or vzext_vl.
+  using namespace SDPatternMatch;
+  SDValue Src;
+  if (!sd_match(Inner, m_OneUse(m_Node(Opcode, m_Value(Src), m_Specific(Mask),
+                                       m_Specific(VL)))))
----------------
lukel97 wrote:

The masked off lanes are undef for zext_vl/sext_vl, so I think we're free to match against any Mask or VL here

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


More information about the llvm-commits mailing list