[llvm] [RISCV][InsertVSETVLI] Remove redundant vsetvli by repeating the coalesce phase (PR #141298)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Fri May 23 15:45:32 PDT 2025


================
@@ -1840,8 +1852,14 @@ bool RISCVInsertVSETVLI::runOnMachineFunction(MachineFunction &MF) {
   // any cross block analysis within the dataflow.  We can't have both
   // demanded fields based mutation and non-local analysis in the
   // dataflow at the same time without introducing inconsistencies.
-  for (MachineBasicBlock &MBB : MF)
-    coalesceVSETVLIs(MBB);
+  using BBPtrIterator = pointer_iterator<MachineFunction::iterator>;
+  SetVector<MachineBasicBlock *> Worklist(BBPtrIterator(MF.begin()),
----------------
mshockwave wrote:

Since we don't always traverse the blocks in topological order, we have to use a set here to avoid enqueuing blocks that will be visit anyway later.

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


More information about the llvm-commits mailing list