[PATCH] D152954: [RISCV] Treat __riscv_vsetvl_*(-1) as vlmax.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 14 13:23:32 PDT 2023


craig.topper created this revision.
craig.topper added reviewers: frasercrmck, rogfer01, kito-cheng, eopXD, arcbbb.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a project: LLVM.

We already treat -1 passed to instruction intrinsics as vlmax, this
make vsetvli consistent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152954

Files:
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll


Index: llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
+++ llvm/test/CodeGen/RISCV/rvv/vsetvli-intrinsics.ll
@@ -126,3 +126,12 @@
   %x = call <vscale x 4 x i32> @llvm.riscv.vle.nxv4i32.iXLen(<vscale x 4 x i32> undef, <vscale x 4 x i32>* %ptr, iXLen %vl1)
   ret <vscale x 4 x i32> %x
 }
+
+define iXLen @test_vsetvli_negone_e8m1(iXLen %avl) nounwind {
+; CHECK-LABEL: test_vsetvli_negone_e8m1:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    vsetvli a0, zero, e8, m1, ta, ma
+; CHECK-NEXT:    ret
+  %vl = call iXLen @llvm.riscv.vsetvli.iXLen(iXLen -1, iXLen 0, iXLen 0)
+  ret iXLen %vl
+}
Index: llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
+++ llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
@@ -583,7 +583,7 @@
 
   SDValue VLOperand;
   unsigned Opcode = RISCV::PseudoVSETVLI;
-  if (VLMax) {
+  if (VLMax || isAllOnesConstant(Node->getOperand(1))) {
     VLOperand = CurDAG->getRegister(RISCV::X0, XLenVT);
     Opcode = RISCV::PseudoVSETVLIX0;
   } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152954.531481.patch
Type: text/x-patch
Size: 1194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230614/5dd532e5/attachment.bin>


More information about the llvm-commits mailing list