Skip to content

Commit c185c2f

Browse files
committed
[CodeGen] For ad hoc aliasing, now each lead node register will have
register unit defined that uniquely identifies them, alongwith a an addtional register unit per edge in ad hoc alias graph that shows the register overlap between the connected aliasing leaf register nodes It solves the issue of using the aliasing register as the immediate subregister of a register, thus need to have disjoint lanemask, which is now possible by virtue of uniquely defined register units. At the same time, aliasing is accounted by the shared register unit, having lanemask as 0x0 just as previously, not a problem now.
1 parent 45a3056 commit c185c2f

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,21 +438,34 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
438438
// These units correspond to the maximal cliques in the register overlap
439439
// graph which is optimal.
440440
//
441-
// When there is ad hoc aliasing, we simply create one unit per edge in the
442-
// undirected ad hoc aliasing graph. Technically, we could do better by
443-
// identifying maximal cliques in the ad hoc graph, but cliques larger than 2
444-
// are extremely rare anyway (I've never seen one), so we don't bother with
445-
// the added complexity.
441+
// When there is ad hoc aliasing, while we create one unit per edge in the
442+
// undirected ad hoc aliasing graph to represent aliasing, one unit per each
443+
// node leaf register is needed extra to identify them uniquely, in case these
444+
// aliasing register are used as subregister(with disjoint lanemasks) to have
445+
// an accurate lanemask generation for these leaf register.
446+
// For example, In VE, SX0 is made out of disjoint subregister SW0 & SF0
447+
// respectively, where SF0 is an alias for SW0. So while 2 register units will
448+
// uniquely define these 2 subregister, the shared register unit will account
449+
// for aliasing.
450+
//
451+
// Technically, we could do better by identifying maximal cliques in the ad
452+
// hoc graph, but cliques larger than 2 are extremely rare anyway (I've never
453+
// seen one), so we don't bother with the added complexity.
446454
for (unsigned i = 0, e = ExplicitAliases.size(); i != e; ++i) {
447455
CodeGenRegister *AR = ExplicitAliases[i];
448456
// Only visit each edge once.
449457
if (AR->SubRegsComplete)
450458
continue;
451459
// Create a RegUnit representing this alias edge, and add it to both
452460
// registers.
453-
unsigned Unit = RegBank.newRegUnit(this, AR);
454-
RegUnits.set(Unit);
455-
AR->RegUnits.set(Unit);
461+
unsigned SharedUnit = RegBank.newRegUnit(this, AR);
462+
RegUnits.set(SharedUnit);
463+
AR->RegUnits.set(SharedUnit);
464+
465+
// Create a RegUnit that now corresponds uniquely to each of the both
466+
// alias leaf register nodes.
467+
RegUnits.set(RegBank.newRegUnit(this));
468+
AR->RegUnits.set(RegBank.newRegUnit(AR));
456469
}
457470

458471
// Finally, create units for leaf registers without ad hoc aliases. Note that
@@ -2721,4 +2734,11 @@ void CodeGenRegBank::printRegUnitName(unsigned Unit) const {
27212734
dbgs() << ' ' << RegUnits[Unit].Roots[0]->getName();
27222735
else
27232736
dbgs() << " #" << Unit;
2737+
2738+
if (RegUnits[Unit].Roots[1]) {
2739+
if (Unit < NumNativeRegUnits)
2740+
dbgs() << '~' << RegUnits[Unit].Roots[1]->getName();
2741+
else
2742+
dbgs() << "~#" << Unit;
2743+
}
27242744
}

0 commit comments

Comments
 (0)