[llvm] [RISCV] Extend redundant vrgather.vx peephole to vfmv.v.f (PR #135503)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 14 15:41:23 PDT 2025


================
@@ -19716,10 +19716,15 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
     SDValue Src = N->getOperand(0);
     SDValue Passthru = N->getOperand(2);
     SDValue VL = N->getOperand(4);
-    // TODO: Handle fmv.v.f?
-    if (Src.getOpcode() == RISCVISD::VMV_V_X_VL && Passthru.isUndef() &&
-        VL == Src.getOperand(2))
-      return Src;
+    switch (Src.getOpcode()) {
+    default:
+      break;
+    case RISCVISD::VMV_V_X_VL:
+    case RISCVISD::VFMV_V_F_VL:
+      if (Passthru.isUndef() && VL == Src.getOperand(2))
+        return Src;
----------------
lukel97 wrote:

I think we could also allow vmv.v.xs with mismatched VLs if their own passthru is undef, e.g.
```suggestion
      if (Passthru.isUndef() && (VL == Src.getOperand(2) || Src.getOperand(0).isUndef()))
        return Src;
```

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


More information about the llvm-commits mailing list