Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check array-shadow symbol and DataType for refineArrayAliasing #7119

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 42 additions & 23 deletions compiler/optimizer/GeneralLoopUnroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,12 @@ bool TR_LoopUnroller::haveIdenticalOffsets(IntrnPtr *intrnPtr1, IntrnPtr *intrnP
return false;
}

bool TR_LoopUnroller::isSymRefSameTypeArrayShadow(TR::Node *node)
{
// Checks that node symbolReference is an array-shadow with the same data type as the node.
return (node->getSymbolReference()->getReferenceNumber() == comp()->getSymRefTab()->getArrayShadowIndex(node->getDataType()));
}

void TR_LoopUnroller::examineArrayAccesses()
{
// What we are trying to achieve here is to allow the possibility to schedule array accesses
Expand Down Expand Up @@ -1696,34 +1702,47 @@ void TR_LoopUnroller::examineArrayAccesses()
//
bool canProve = true;
ListIterator<ArrayAccess> it1(loaa->list);
ArrayAccess *aa1;
ArrayAccess *aa2;
for (aa1 = it1.getFirst(); aa1 && (aa2 = it1.getNext()); aa1 = aa2)
{
if (trace())
traceMsg(comp(), "\tComparing array accesses %p and %p\n", aa1->aaNode, aa2->aaNode);
ArrayAccess *aa1, *aa2;
aa1 = it1.getFirst();

// Do not take care of array accesses without internal pointers at this point.
//
if (!aa1->intrnPtrNode || !aa2->intrnPtrNode)
// Ensures that the symbolReference is an array-shadow with the same data type as the node.
if (!isSymRefSameTypeArrayShadow(aa1->aaNode))
canProve = false;
else
{
for (; aa1 && (aa2 = it1.getNext()); aa1 = aa2)
{
if (trace())
traceMsg(comp(), "\tComparing array accesses %p and %p\n", aa1->aaNode, aa2->aaNode);

if (!isSymRefSameTypeArrayShadow(aa2->aaNode))
{
canProve = false;
break;
}

// Do not take care of array accesses without internal pointers at this point.
//
if (!aa1->intrnPtrNode || !aa2->intrnPtrNode)
{
canProve = false;
break;
}

IntrnPtr *intrnPtr1 = findIntrnPtr(aa1->intrnPtrNode->getSymbolReference()->getReferenceNumber());
IntrnPtr *intrnPtr2 = findIntrnPtr(aa2->intrnPtrNode->getSymbolReference()->getReferenceNumber());
if (intrnPtr1 && intrnPtr2)
{
if (aa1->intrnPtrNode == aa2->intrnPtrNode)
continue;
if (intrnPtr1->offsetNode == intrnPtr2->offsetNode)
continue;
if (haveIdenticalOffsets(intrnPtr1, intrnPtr2))
continue;
}
canProve = false;
break;
}

IntrnPtr *intrnPtr1 = findIntrnPtr(aa1->intrnPtrNode->getSymbolReference()->getReferenceNumber());
IntrnPtr *intrnPtr2 = findIntrnPtr(aa2->intrnPtrNode->getSymbolReference()->getReferenceNumber());
if (intrnPtr1 && intrnPtr2)
{
if (aa1->intrnPtrNode == aa2->intrnPtrNode)
continue;
if (intrnPtr1->offsetNode == intrnPtr2->offsetNode)
continue;
if (haveIdenticalOffsets(intrnPtr1, intrnPtr2))
continue;
}
canProve = false;
break;
}

if (!canProve || !aa1->intrnPtrNode) // if cannot prove or if there is only one element in the list
Expand Down
1 change: 1 addition & 0 deletions compiler/optimizer/GeneralLoopUnroller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class TR_LoopUnroller
struct IntrnPtr;
IntrnPtr *findIntrnPtr(int32_t symRefNum);
bool haveIdenticalOffsets(IntrnPtr *intrnPtr1, IntrnPtr *intrnPtr2);
bool isSymRefSameTypeArrayShadow(TR::Node *node);
void examineArrayAccesses();
void refineArrayAliasing();

Expand Down