[llvm] [RegAllocFast] Allocate tied uses first and enable for PowerPC (PR #229672)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 01:08:04 PDT 2026
MaskRay wrote:
> What's the perf impact of scanning all operands twice if there's a tied def? On x86, this is rather common.
>
> Code LGTM otherwise.
There is a minor overhead
https://llvm-compile-time-tracker.com/compare.php?from=906e3ec0647aef01363973edf3cb0104a812589a&to=b905d97a4fc46b9e6f8454cb41c6ba9c9416c141&stat=instructions:u
O0-g +0.02–0.03%, O3/LTO flat, size-text unchanged on x86 and AArch64 (no instruction there has an untied read before its tied use). The cost is the second operand walk for tied-def instructions.
The overhead can likely be fixed with slightly more code
```patch
--- i/llvm/lib/CodeGen/RegAllocFast.cpp
+++ w/llvm/lib/CodeGen/RegAllocFast.cpp
@@ -1655,3 +1655,4 @@ void RegAllocFastImpl::allocateInstruction(MachineInstr &MI) {
bool HasEarlyClobber = false;
- bool HasTiedDef = false;
+ bool HasUntiedUse = false;
+ bool HasLateTiedUse = false;
bool NeedToAssignLiveThroughs = false;
@@ -1668,6 +1669,8 @@ void RegAllocFastImpl::allocateInstruction(MachineInstr &MI) {
HasEarlyClobber = true;
- if (LowerTiedOps && MO.isTied())
- HasTiedDef = true;
if (isLiveThroughDef(MI, MO))
NeedToAssignLiveThroughs = true;
+ } else if (!MO.isTied()) {
+ HasUntiedUse = true;
+ } else if (HasUntiedUse && LowerTiedOps) {
+ HasLateTiedUse = true;
}
@@ -1816,3 +1819,3 @@ void RegAllocFastImpl::allocateInstruction(MachineInstr &MI) {
bool HasUndefUse = false;
- bool TiedOnly = HasTiedDef;
+ bool TiedOnly = HasLateTiedUse;
bool ReArrangedImplicitMOs = true;
```
https://github.com/llvm/llvm-project/pull/229672
More information about the llvm-commits
mailing list