[llvm] [RegAllocFast] Replace UsedInInstr with vector (PR #96323)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 10:30:24 PDT 2024
================
@@ -253,11 +253,19 @@ class RegAllocFastImpl {
SmallVector<MachineInstr *, 32> Coalesced;
- using RegUnitSet = SparseSet<uint16_t, identity<uint16_t>>;
- /// Set of register units that are used in the current instruction, and so
+ /// Track register units that are used in the current instruction, and so
/// cannot be allocated.
- RegUnitSet UsedInInstr;
- RegUnitSet PhysRegUses;
+ ///
+ /// In the first phase (tied defs/early clobber), we consider also physical
+ /// uses, afterwards, we don't. if the lowest bit isn't set, it's a solely
+ /// physical use (markPhysRegUsedInInstr), otherwise, it's a normal use. To
+ /// avoid resetting the entire vector after every instruction, we track the
+ /// instruction "generation" in the remaining 31 bits -- this meands, that if
+ /// UsedInInstr[Idx] < InstrGen, the register unit is unused. InstrGen is
+ /// never zero and always incremented by two.
+ uint32_t InstrGen;
+ SmallVector<unsigned, 0> UsedInInstr;
----------------
aengelke wrote:
There are only very few targets with a reasonably small number of reg units (smallest I think is BPF with 12, but most have ~100, AMDGPU over 1k) -- adding an almost never used inline storage doesn't really make sense and the allocation is done just once per module.
https://github.com/llvm/llvm-project/pull/96323
More information about the llvm-commits
mailing list