[PATCH] D125079: [fastregalloc] Enhance the heuristics for liveout in self loop.
LuoYuanke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 01:27:47 PDT 2022
LuoYuanke updated this revision to Diff 427554.
LuoYuanke added a comment.
Herald added a subscriber: pengfei.
Rebase.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125079/new/
https://reviews.llvm.org/D125079
Files:
llvm/lib/CodeGen/RegAllocFast.cpp
llvm/test/CodeGen/X86/fastregalloc-selfloop.mir
Index: llvm/test/CodeGen/X86/fastregalloc-selfloop.mir
===================================================================
--- llvm/test/CodeGen/X86/fastregalloc-selfloop.mir
+++ llvm/test/CodeGen/X86/fastregalloc-selfloop.mir
@@ -14,11 +14,10 @@
machineFunctionInfo: {}
body: |
bb.0.entry:
- ; CHECK: renamable $xmm1 = V_SET0
+ ; CHECK: renamable $xmm1 = V_SET0
; CHECK-NEXT: renamable $xmm0 = V_SET0
; CHECK-NEXT: renamable $xmm1 = PXORrr renamable $xmm1, renamable $xmm0
- ; CHECK-NEXT: MOVAPSmr %stack.1, 1, $noreg, 0, $noreg, $xmm1 :: (store (s128) into %stack.1)
- ; CHECK-NEXT: MOVAPSmr %stack.0, 1, $noreg, 0, $noreg, renamable $xmm1
+ ; CHECK-NEXT: MOVAPSmr %stack.0, 1, $noreg, 0, $noreg, killed renamable $xmm1
; CHECK-NEXT: MOVAPSmr %stack.0, 1, $noreg, 16, $noreg, killed renamable $xmm0
%0:vr128 = V_SET0
Index: llvm/lib/CodeGen/RegAllocFast.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocFast.cpp
+++ llvm/lib/CodeGen/RegAllocFast.cpp
@@ -359,7 +359,13 @@
// If this block loops back to itself, it is necessary to check whether the
// use comes after the def.
if (MBB->isSuccessor(MBB)) {
- SelfLoopDef = MRI->getUniqueVRegDef(VirtReg);
+ // Find the first the def in the self loop MBB.
+ for (const MachineInstr &DefInst : MRI->def_instructions(VirtReg)) {
+ if (DefInst.getParent() == MBB) {
+ if (!SelfLoopDef || dominates(*MBB, DefInst.getIterator(), SelfLoopDef))
+ SelfLoopDef = &DefInst;
+ }
+ }
if (!SelfLoopDef) {
MayLiveAcrossBlocks.set(Register::virtReg2Index(VirtReg));
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125079.427554.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220506/77d910ac/attachment-0001.bin>
More information about the llvm-commits
mailing list