[PATCH] D121277: [MachineSink] Check block prologue does not clobber uses

Carl Ritson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 23:22:36 PDT 2022


critson marked an inline comment as done.
critson added a comment.

In D121277#3384816 <https://reviews.llvm.org/D121277#3384816>, @ruiling wrote:

> Try this. I don't know what would be the most likely pattern in real cases, this is just to show that sinking $sgpr0_sgpr1 definition instruction into successor block would break the register dependency of type (a).
>
>   snipped

Thanks for this example. I used this as a basis for a test case, but used separate sources for the two COPY instructions.



================
Comment at: llvm/lib/CodeGen/MachineSink.cpp:1812-1827
+    if (InsertPos != SuccBB->begin()) {
+      bool UsesClobbered = false;
+      for (MachineBasicBlock::iterator PI = SuccBB->begin();
+           PI != InsertPos && !UsesClobbered; ++PI) {
+        for (auto U : UsedOpsInCopy) {
+          Register SrcReg = MI.getOperand(U).getReg();
+          if (PI->modifiesRegister(SrcReg, TRI)) {
----------------
arsenm wrote:
> Is there not a helper for this somewhere?
I could not see immediately find one.
Also the newer code is now special cased to only operate on target defined block prologue instructions, which is more efficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121277



More information about the llvm-commits mailing list