Commit 6580e172 authored by Junjie Gu's avatar Junjie Gu Committed by gbsbuild

Do isolation on mis-aligned values out of DOM traveral. This could potentially

change the final congrurent class. But we expect the change would be minor, and
for corner case only

Change-Id: I0d618c312e04aca70e29c044e8f9c1b2045a43cc
parent 59ac055c
......@@ -310,8 +310,10 @@ bool DeSSA::runOnFunction(Function &MF) {
CurrentDominatingParent,
ImmediateDominatingParent);
}
SplitInterferencesForAlignment(CurrentDominatingParent);
}
// Handle values that have specific alignment requirement.
SplitInterferencesForAlignment();
return false;
}
......@@ -637,53 +639,65 @@ DeSSA::SplitInterferencesForArgument(
}
}
void
DeSSA::SplitInterferencesForAlignment(
DenseMap<Value*, Value*> &CurrentDominatingParent) {
for (auto I = CurrentDominatingParent.begin(),
E = CurrentDominatingParent.end(); I != E; ++I) {
auto RI = RegNodeMap.find(I->first);
if (RI == RegNodeMap.end())
continue;
void DeSSA::SplitInterferencesForAlignment()
{
for (auto I = RegNodeMap.begin(), E = RegNodeMap.end(); I != E; ++I)
{
// Find a root Node
Node *rootNode = I->second;
if (rootNode->parent.getPointer() != rootNode) {
continue;
}
e_alignment Align = EALIGN_AUTO;
// Find the most restrictive alignment, i.e. GRF aligned ones.
Node *TheNode = RI->second;
Node *LI = TheNode;
do {
// Skip isolated reg.
if (LI->parent.getInt() & Node::kRegisterIsolatedFlag) {
LI = LI->next;
continue;
}
e_alignment Align = EALIGN_AUTO;
// Find the most restrictive alignment, i.e. GRF aligned ones.
Node *N = rootNode;
Node *Curr;
do {
Curr = N;
N = Curr->next;
// Skip isolated reg.
if (Curr->parent.getInt() &
(Node::kRegisterIsolatedFlag | Node::kPHIIsolatedFlag)) {
continue;
}
if (LI->alignment == EALIGN_GRF) {
Align = EALIGN_GRF;
break;
}
if (Curr->alignment == EALIGN_GRF) {
Align = EALIGN_GRF;
break;
}
} while (N != rootNode);
LI = LI->next;
} while (LI != TheNode);
if (Align != EALIGN_GRF)
continue;
// Isolate mismatching alignment.
LI = TheNode;
do {
// Skip isolated reg.
if (LI->parent.getInt() & Node::kRegisterIsolatedFlag) {
LI = LI->next;
continue;
}
// Isolate any mis-aligned value.
// Start with Curr node as it cannot be isolated
// (rootNode could be isolated), therefore, it remains
// in the linked list and can be used to test stop looping.
Node* Head = Curr;
N = Head;
do {
Curr = N;
N = N->next;
// Skip isolated reg.
if (Curr->parent.getInt() &
(Node::kRegisterIsolatedFlag | Node::kPHIIsolatedFlag)) {
continue;
}
if (Align == EALIGN_GRF &&
(LI->alignment != EALIGN_AUTO && LI->alignment != EALIGN_GRF)) {
isolateReg(LI->value);
}
LI = LI->next;
} while (LI != TheNode);
if (Curr->alignment != EALIGN_AUTO && Curr->alignment != EALIGN_GRF)
{
assert(Curr != Head && "Head Node cannot be isolated, something wrong!");
isolateReg(Curr->value);
}
} while (N != Head);
// Update root's alignment.
TheNode->alignment = Align;
}
// Update root's alignment.
Head->getLeader()->alignment = Align;
}
}
Value*
......
......@@ -211,8 +211,7 @@ class DeSSA : public llvm::FunctionPass {
llvm::DenseMap<llvm::Value*, llvm::Value*> &CurrentDominatingParent,
llvm::DenseMap<llvm::Value*, llvm::Value*> &ImmediateDominatingParent);
void SplitInterferencesForAlignment(
llvm::DenseMap<llvm::Value*, llvm::Value*> &CurrentDominatingParent);
void SplitInterferencesForAlignment();
llvm::DominatorTree *DT;
LiveVars *LV;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment