From: Krzysztof Parzyszek Date: Tue, 4 Aug 2020 22:46:38 +0000 (-0500) Subject: [RDF] Cache register aliases in PhysicalRegisterInfo X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0f467aeecfc615a5055d8f2edd903996c11727e;p=platform%2Fupstream%2Fllvm.git [RDF] Cache register aliases in PhysicalRegisterInfo This improves performance of PhysicalRegisterInfo::makeRegRef. --- diff --git a/llvm/include/llvm/CodeGen/RDFRegisters.h b/llvm/include/llvm/CodeGen/RDFRegisters.h index e8ba010..82388dc 100644 --- a/llvm/include/llvm/CodeGen/RDFRegisters.h +++ b/llvm/include/llvm/CodeGen/RDFRegisters.h @@ -132,6 +132,10 @@ namespace rdf { return MaskInfos[Register::stackSlot2Index(MaskId)].Units; } + const BitVector &getUnitAliases(uint32_t U) const { + return AliasInfos[U].Regs; + } + RegisterRef mapTo(RegisterRef RR, unsigned R) const; const TargetRegisterInfo &getTRI() const { return TRI; } @@ -146,12 +150,16 @@ namespace rdf { struct MaskInfo { BitVector Units; }; + struct AliasInfo { + BitVector Regs; + }; const TargetRegisterInfo &TRI; IndexedSet RegMasks; std::vector RegInfos; std::vector UnitInfos; std::vector MaskInfos; + std::vector AliasInfos; bool aliasRR(RegisterRef RA, RegisterRef RB) const; bool aliasRM(RegisterRef RR, RegisterRef RM) const; diff --git a/llvm/lib/CodeGen/RDFRegisters.cpp b/llvm/lib/CodeGen/RDFRegisters.cpp index 9f8d6b9..c76447d 100644 --- a/llvm/lib/CodeGen/RDFRegisters.cpp +++ b/llvm/lib/CodeGen/RDFRegisters.cpp @@ -92,6 +92,15 @@ PhysicalRegisterInfo::PhysicalRegisterInfo(const TargetRegisterInfo &tri, } MaskInfos[M].Units = PU.flip(); } + + AliasInfos.resize(TRI.getNumRegUnits()); + for (uint32_t U = 0, NU = TRI.getNumRegUnits(); U != NU; ++U) { + BitVector AS(TRI.getNumRegs()); + for (MCRegUnitRootIterator R(U, &TRI); R.isValid(); ++R) + for (MCSuperRegIterator S(*R, &TRI, true); S.isValid(); ++S) + AS.set(*S); + AliasInfos[U].Regs = AS; + } } std::set PhysicalRegisterInfo::getAliasSet(RegisterId Reg) const { @@ -317,26 +326,17 @@ RegisterRef RegisterAggr::makeRegRef() const { if (U < 0) return RegisterRef(); - auto AliasedRegs = [this] (uint32_t Unit, BitVector &Regs) { - for (MCRegUnitRootIterator R(Unit, &PRI.getTRI()); R.isValid(); ++R) - for (MCSuperRegIterator S(*R, &PRI.getTRI(), true); S.isValid(); ++S) - Regs.set(*S); - }; - // Find the set of all registers that are aliased to all the units // in this aggregate. // Get all the registers aliased to the first unit in the bit vector. - BitVector Regs(PRI.getTRI().getNumRegs()); - AliasedRegs(U, Regs); + BitVector Regs = PRI.getUnitAliases(U); U = Units.find_next(U); // For each other unit, intersect it with the set of all registers // aliased that unit. while (U >= 0) { - BitVector AR(PRI.getTRI().getNumRegs()); - AliasedRegs(U, AR); - Regs &= AR; + Regs &= PRI.getUnitAliases(U); U = Units.find_next(U); }