Skip to content

Commit 5b309af

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 03d3e6d commit 5b309af

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
@@ -424,20 +424,33 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
424424
// These units correspond to the maximal cliques in the register overlap
425425
// graph which is optimal.
426426
//
427-
// When there is ad hoc aliasing, we simply create one unit per edge in the
428-
// undirected ad hoc aliasing graph. Technically, we could do better by
429-
// identifying maximal cliques in the ad hoc graph, but cliques larger than 2
430-
// are extremely rare anyway (I've never seen one), so we don't bother with
431-
// the added complexity.
427+
// When there is ad hoc aliasing, while we create one unit per edge in the
428+
// undirected ad hoc aliasing graph to represent aliasing, one unit per each
429+
// node leaf register is needed extra to identify them uniquely, in case these
430+
// aliasing register are used as subregister(with disjoint lanemasks) to have
431+
// an accurate lanemask generation for these leaf register.
432+
// For example, In VE, SX0 is made out of disjoint subregister SW0 & SF0
433+
// respectively, where SF0 is an alias for SW0. So while 2 register units will
434+
// uniquely define these 2 subregister, the shared register unit will account
435+
// for aliasing.
436+
//
437+
// Technically, we could do better by identifying maximal cliques in the ad
438+
// hoc graph, but cliques larger than 2 are extremely rare anyway (I've never
439+
// seen one), so we don't bother with the added complexity.
432440
for (CodeGenRegister *AR : ExplicitAliases) {
433441
// Only visit each edge once.
434442
if (AR->SubRegsComplete)
435443
continue;
436444
// Create a RegUnit representing this alias edge, and add it to both
437445
// registers.
438-
unsigned Unit = RegBank.newRegUnit(this, AR);
439-
RegUnits.set(Unit);
440-
AR->RegUnits.set(Unit);
446+
unsigned SharedUnit = RegBank.newRegUnit(this, AR);
447+
RegUnits.set(SharedUnit);
448+
AR->RegUnits.set(SharedUnit);
449+
450+
// Create a RegUnit that now corresponds uniquely to each of the both
451+
// alias leaf register nodes.
452+
RegUnits.set(RegBank.newRegUnit(this));
453+
AR->RegUnits.set(RegBank.newRegUnit(AR));
441454
}
442455

443456
// Finally, create units for leaf registers without ad hoc aliases. Note that
@@ -2675,6 +2688,13 @@ void CodeGenRegBank::printRegUnitNames(ArrayRef<unsigned> Units) const {
26752688
dbgs() << ' ' << RegUnits[Unit].Roots[0]->getName();
26762689
else
26772690
dbgs() << " #" << Unit;
2691+
2692+
if (RegUnits[Unit].Roots[1]) {
2693+
if (Unit < NumNativeRegUnits)
2694+
dbgs() << '~' << RegUnits[Unit].Roots[1]->getName();
2695+
else
2696+
dbgs() << "~#" << Unit;
2697+
}
26782698
}
26792699
dbgs() << '\n';
26802700
}

0 commit comments

Comments
 (0)