summaryrefslogtreecommitdiff
path: root/utils/TableGen/DAGISelEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/DAGISelEmitter.cpp')
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index 8816c9c0e7..03a12cd13d 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -174,8 +174,14 @@ struct PatternSortingPredicate {
if (LHSCost < RHSCost) return true;
if (LHSCost > RHSCost) return false;
- return getResultPatternSize(LHS->getDstPattern(), CGP) <
- getResultPatternSize(RHS->getDstPattern(), CGP);
+ unsigned LHSPatSize = getResultPatternSize(LHS->getDstPattern(), CGP);
+ unsigned RHSPatSize = getResultPatternSize(RHS->getDstPattern(), CGP);
+ if (LHSPatSize < RHSPatSize) return true;
+ if (LHSPatSize > RHSPatSize) return false;
+
+ // Sort based on the UID of the pattern, giving us a deterministic ordering.
+ assert(LHS->ID != RHS->ID);
+ return LHS->ID < RHS->ID;
}
};
}