[PATCH] D126048: [SplitKit] Handle early clobber + tied to def correctly

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 17:02:00 PDT 2022


MatzeB added a comment.

This seems to make sense to me (though I am not super familiar with the code here). Some ideas for clearer code below:



================
Comment at: llvm/lib/CodeGen/SplitKit.cpp:1355-1381
       Idx = Idx.getPrevSlot();
       if (!Edit->getParent().liveAt(Idx))
         continue;
     } else
       Idx = Idx.getRegSlot(true);
 
     SlotIndex Next = Idx.getNextSlot();
----------------
Hmm I found the (existing) logic here somewhat confusing... line 1361 doing getNextSlot() just seems to counteract line 1355 moving to the previous slot, but forces line 1359 to unnaturally chose the early clobber slot.

Anyway can we streamline the code somewhat like this:


================
Comment at: llvm/lib/CodeGen/SplitKit.cpp:1376
+      // in [16e, 32d).
+      unsigned OpIdx = MI->findRegisterUseOperandIdx(MO.getReg());
+      unsigned DefOpIdx = MI->findTiedOperandIdx(OpIdx);
----------------
Use `getOperandNo` that's faster and avoids trouble if multiple operands use the same register.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126048



More information about the llvm-commits mailing list