[PATCH] D126563: [RISCV] Allow PRE of vsetvli involving non-1 LMUL

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 13:28:16 PDT 2022


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

This is a follow up to address a review comment from D124869 <https://reviews.llvm.org/D124869>.  When deciding whether to PRE a vsetvli, we can allow non-LMUL1 vsetvlis.

Despite posting this, I'm not sure we should land it.  I think it is correct, but it also appears to be dead code today.  All of the examples I've played with involving non-1 LMULs hit other problems first, and we never actually get to this.  Thoughts?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126563

Files:
  llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp


Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -1283,14 +1283,17 @@
     // vreg def placement.
     return RISCV::X0 == Info.getAVLReg();
 
-  if (RISCVII::LMUL_1 != Info.getVLMUL())
-    // TODO: Generalize the code below to account for LMUL
-    return false;
-
   unsigned AVL = Info.getAVLImm();
   unsigned SEW = Info.getSEW();
   unsigned AVLInBits = AVL * SEW;
-  return ST.getRealMinVLen() >= AVLInBits;
+
+  unsigned LMul;
+  bool Fractional;
+  std::tie(LMul, Fractional) = RISCVVType::decodeVLMUL(Info.getVLMUL());
+
+  if (Fractional)
+    return ST.getRealMinVLen() / LMul >= AVLInBits;
+  return ST.getRealMinVLen() * LMul >= AVLInBits;
 }
 
 /// Perform simple partial redundancy elimination of the VSETVLI instructions


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126563.432613.patch
Type: text/x-patch
Size: 910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220527/7d14aa1e/attachment.bin>


More information about the llvm-commits mailing list