return ReachibilityMatrix[Idx / 8] & (1 << (Idx % 8));
}
return ReachibilityMatrix[Idx / 8] & (1 << (Idx % 8));
}
+ /// UnfoldableSet - An boolean array representing nodes which have been
+ /// folded into addressing modes and therefore should not be folded in
+ /// another operation.
+ unsigned char *UnfoldableSet;
+
+ inline void setUnfoldable(SDNode *N) {
+ unsigned Id = N->getNodeId();
+ UnfoldableSet[Id / 8] |= 1 << (Id % 8);
+ }
+
+ inline bool isUnfoldable(SDNode *N) {
+ unsigned Id = N->getNodeId();
+ return UnfoldableSet[Id / 8] & (1 << (Id % 8));
+ }
+
#ifndef NDEBUG
unsigned Indent;
#endif
#ifndef NDEBUG
unsigned Indent;
#endif
}
bool X86DAGToDAGISel::IsFoldableBy(SDNode *N, SDNode *U) {
}
bool X86DAGToDAGISel::IsFoldableBy(SDNode *N, SDNode *U) {
+ // Is it already folded by SelectAddr / SelectLEAAddr?
+ if (isUnfoldable(N))
+ return false;
+
// If U use can somehow reach N through another path then U can't fold N or
// it will create a cycle. e.g. In the following diagram, U can reach N
// through X. If N is foled into into U, then X is both a predecessor and
// If U use can somehow reach N through another path then U can't fold N or
// it will create a cycle. e.g. In the following diagram, U can reach N
// through X. If N is foled into into U, then X is both a predecessor and
MachineFunction::iterator FirstMBB = BB;
DAGSize = DAG.AssignNodeIds();
MachineFunction::iterator FirstMBB = BB;
DAGSize = DAG.AssignNodeIds();
+ unsigned NumBytes = (DAGSize+7) / 8;
+ UnfoldableSet = new unsigned char[NumBytes];
+ memset(UnfoldableSet, 0, NumBytes);
+
DetermineTopologicalOrdering();
// Codegen the basic block.
DetermineTopologicalOrdering();
// Codegen the basic block.
delete[] TopOrder;
delete[] IdToOrder;
delete[] RMRange;
delete[] TopOrder;
delete[] IdToOrder;
delete[] RMRange;
+ delete[] UnfoldableSet;
ReachibilityMatrix = NULL;
TopOrder = NULL;
IdToOrder = RMRange = NULL;
ReachibilityMatrix = NULL;
TopOrder = NULL;
IdToOrder = RMRange = NULL;
CodeGenMap.clear();
HandleMap.clear();
ReplaceMap.clear();
CodeGenMap.clear();
HandleMap.clear();
ReplaceMap.clear();
getAddressOperands(AM, Base, Scale, Index, Disp);
getAddressOperands(AM, Base, Scale, Index, Disp);
+ int Id = Base.Val ? Base.Val->getNodeId() : -1;
+ if (Id != -1)
+ setUnfoldable(Base.Val);
+ Id = Index.Val ? Index.Val->getNodeId() : -1;
+ if (Id != -1)
+ setUnfoldable(Index.Val);
+
+ int Id = Base.Val ? Base.Val->getNodeId() : -1;
+ if (Id != -1)
+ setUnfoldable(Base.Val);
+ Id = Index.Val ? Index.Val->getNodeId() : -1;
+ if (Id != -1)
+ setUnfoldable(Index.Val);
+