[PATCH] D131932: RAGreedyStats: Ignore identity COPYs; count COPYs from/to physregs
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 16:03:45 PDT 2022
MatzeB updated this revision to Diff 453148.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131932/new/
https://reviews.llvm.org/D131932
Files:
llvm/lib/CodeGen/RegAllocGreedy.cpp
llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
llvm/test/CodeGen/X86/statepoint-ra.ll
Index: llvm/test/CodeGen/X86/statepoint-ra.ll
===================================================================
--- llvm/test/CodeGen/X86/statepoint-ra.ll
+++ llvm/test/CodeGen/X86/statepoint-ra.ll
@@ -20,10 +20,6 @@
;YAML: - String: ' total reloads cost '
;YAML: - NumZeroCostFoldedReloads: '20'
;YAML: - String: ' zero cost folded reloads '
-;YAML: - NumVRCopies: '2'
-;YAML: - String: ' virtual registers copies '
-;YAML: - TotalCopiesCost: '8.882868e-16'
-;YAML: - String: ' total copies cost '
;YAML: - String: generated in function
define void @barney(ptr addrspace(1) %arg, double %arg1, double %arg2, double %arg3, double %arg4, double %arg5, double %arg6, double %arg7, double %arg8, double %arg9, double %arg10, double %arg11, double %arg12) gc "statepoint-example" personality ptr @widget {
Index: llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
+++ llvm/test/CodeGen/AArch64/arm64-spill-remarks.ll
@@ -21,16 +21,16 @@
; (loop2:)
; REMARK: remark: /tmp/kk.c:2:20: 1 spills 1.000000e+04 total spills cost 1 reloads 1.000000e+04 total reloads cost generated in loop{{$}}
; (loop:)
-; REMARK: remark: /tmp/kk.c:1:20: 2 spills 1.010000e+04 total spills cost 2 reloads 1.010000e+04 total reloads cost generated in loop{{$}}
+; REMARK: remark: /tmp/kk.c:1:20: 2 spills 1.010000e+04 total spills cost 2 reloads 1.010000e+04 total reloads cost 1 virtual registers copies 1.000000e+02 total copies cost generated in loop{{$}}
; (func:)
-; REMARK: remark: /tmp/kk.c:1:1: 3 spills 1.020000e+04 total spills cost 3 reloads 1.020000e+04 total reloads cost generated in function
+; REMARK: remark: /tmp/kk.c:1:1: 3 spills 1.020000e+04 total spills cost 3 reloads 1.020000e+04 total reloads cost 3 virtual registers copies 1.020000e+02 total copies cost generated in function{{$}}
; (loop3:)
; HOTNESS: remark: /tmp/kk.c:3:20: 1 spills 1.000000e+02 total spills cost 1 reloads 1.000000e+02 total reloads cost generated in loop (hotness: 300)
; (loop2:)
; HOTNESS: remark: /tmp/kk.c:2:20: 1 spills 1.000000e+04 total spills cost 1 reloads 1.000000e+04 total reloads cost generated in loop (hotness: 30000)
; (loop:)
-; HOTNESS: remark: /tmp/kk.c:1:20: 2 spills 1.010000e+04 total spills cost 2 reloads 1.010000e+04 total reloads cost generated in loop (hotness: 300)
+; HOTNESS: remark: /tmp/kk.c:1:20: 2 spills 1.010000e+04 total spills cost 2 reloads 1.010000e+04 total reloads cost 1 virtual registers copies 1.000000e+02 total copies cost generated in loop (hotness: 300)
; NO_REMARK-NOT: remark
@@ -86,6 +86,10 @@
; YAML: - String: ' reloads '
; YAML: - TotalReloadsCost: '1.010000e+04'
; YAML: - String: ' total reloads cost '
+; YAML: - NumVRCopies: '1'
+; YAML: - String: ' virtual registers copies '
+; YAML: - TotalCopiesCost: '1.000000e+02'
+; YAML: - String: ' total copies cost '
; YAML: - String: generated in loop
; YAML: ...
; YAML: --- !Missed
@@ -103,6 +107,10 @@
; YAML: - String: ' reloads '
; YAML: - TotalReloadsCost: '1.020000e+04'
; YAML: - String: ' total reloads cost '
+; YAML: - NumVRCopies: '3'
+; YAML: - String: ' virtual registers copies '
+; YAML: - TotalCopiesCost: '1.020000e+02'
+; YAML: - String: ' total copies cost '
; YAML: - String: generated in function
; YAML: ...
Index: llvm/lib/CodeGen/RegAllocGreedy.cpp
===================================================================
--- llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -2369,11 +2369,25 @@
};
for (MachineInstr &MI : MBB) {
if (MI.isCopy()) {
- MachineOperand &Dest = MI.getOperand(0);
- MachineOperand &Src = MI.getOperand(1);
- if (Dest.isReg() && Src.isReg() && Dest.getReg().isVirtual() &&
- Src.getReg().isVirtual())
- ++Stats.Copies;
+ const MachineOperand &Dest = MI.getOperand(0);
+ const MachineOperand &Src = MI.getOperand(1);
+ Register SrcReg = Src.getReg();
+ Register DestReg = Dest.getReg();
+ // Only count `COPY`s with a virtual register as source or destination.
+ if (SrcReg.isVirtual() || DestReg.isVirtual()) {
+ if (SrcReg.isVirtual()) {
+ SrcReg = VRM->getPhys(SrcReg);
+ if (Src.getSubReg())
+ SrcReg = TRI->getSubReg(SrcReg, Src.getSubReg());
+ }
+ if (DestReg.isVirtual()) {
+ DestReg = VRM->getPhys(DestReg);
+ if (Dest.getSubReg())
+ DestReg = TRI->getSubReg(DestReg, Dest.getSubReg());
+ }
+ if (SrcReg != DestReg)
+ ++Stats.Copies;
+ }
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131932.453148.patch
Type: text/x-patch
Size: 4854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220816/07ee3404/attachment.bin>
More information about the llvm-commits
mailing list