[PATCH] D149658: [RISCV] Use vslidedown for undef sub-sequences in generic build_vector

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 04:54:26 PDT 2023


luke accepted this revision.
luke added a comment.
This revision is now accepted and ready to land.

The gist of this LGTM

> Another question - mostly for a possible follow-on. The codegen this produces for a build_vector which ends with a undef sub-sequence is a series of vslide1downs + a one vslidedown at the end. An alternate result would be to change VL, and directly insert into the desired positions. The tradeoff is between a vsetvli toggle (which would be largely unremovable) and an extra vslidedown. I'm leaning towards keeping this codegen, does that seem like the right outcome?

Does it depend if a vsetvli toggle is cheaper than a vslidedown that touches n lanes? Either way I'm happy with the current approach.



================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:3215
+      SDValue Ops[] = {DAG.getUNDEF(ContainerVT), Vec, Offset, Mask, VL, PolicyOp};
+      Vec = DAG.getNode(RISCVISD::VSLIDEDOWN_VL, DL, ContainerVT, Ops);
+      UndefCount = 0;
----------------
Could we reuse `getVSlidedown` here?


================
Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:3225
+    Vec = DAG.getNode(RISCVISD::VSLIDEDOWN_VL, DL, ContainerVT, Ops);
+    UndefCount = 0;
+  }
----------------
Nit, we can remove this assignment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149658/new/

https://reviews.llvm.org/D149658



More information about the llvm-commits mailing list