[PATCH] D143335: [AMDGPU] Use instruction order in machine function to process workList of moveToVALU

krishna chaitanya sankisa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 20:06:39 PST 2023


skc7 added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:69
+    return {};
+  ReversePostOrderTraversal<const MachineBasicBlock *> RPOT(&*MF->begin());
+  std::vector<const MachineBasicBlock *> RPOList;
----------------
arsenm wrote:
> It doesn't make sense to me to construct RPO to create a list like this. The whole iteration would just work in RPO
AFAIU, MBB order is created using RPOT list. New MBB might get created by legalizeOperands method once an instruction is processed in the worklist and the MBB order might change. So this list needs to be re-generated.
This list will be used by Cmp::Operator() to compare instructions from two different basic blocks.  


================
Comment at: llvm/lib/Target/AMDGPU/SIInstrInfo.cpp:75-77
+// Compare machine instructions based on their order
+// in the machine function. Returns true if first instruction
+// occurs before second instruction in the machine function.
----------------
arsenm wrote:
> This should be implied by the iteration order, shouldn't need to sort
New MachineInstructions might get added to worklist after it gets processed by legalizeOperands. So we need to maintain a sorted order of worklist. So, we need a Cmp::operator() for sort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143335



More information about the llvm-commits mailing list