[llvm] [RISCV] Move RISCVInsertVSETVLI to after phi elimination (PR #91440)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 11:52:31 PDT 2024


================
@@ -541,9 +541,16 @@ void RISCVPassConfig::addPreRegAlloc() {
   addPass(createRISCVPreRAExpandPseudoPass());
   if (TM->getOptLevel() != CodeGenOptLevel::None)
     addPass(createRISCVMergeBaseOffsetOptPass());
+
   addPass(createRISCVInsertReadWriteCSRPass());
   addPass(createRISCVInsertWriteVXRMPass());
-  addPass(createRISCVInsertVSETVLIPass());
+
+  // Run RISCVInsertVSETVLI after PHI elimination. On O1 and above do it after
+  // register coalescing so needVSETVLIPHI doesn't need to look through COPYs.
+  if (TM->getOptLevel() == CodeGenOptLevel::None)
+    insertPass(&PHIEliminationID, createRISCVInsertVSETVLIPass());
----------------
lukel97 wrote:

> A quick fix for this particular PR can be using `insertPass(&PHIEliminationID, &RISCVInsertVSETVLIID);` (although I guess we don't have a PassID for RISCVInsertVSETVLI?) The `insertPass` in this form won't cause the problem since it creates `Pass` pointer on-demand/on-the-fly rather than storing it.

Oh good idea, I didn't realise that that would defer creating it. Will give that a shot instead

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


More information about the llvm-commits mailing list