From 117ccb7e518f05e4bf3df058fc402262f897ff0b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 1 Mar 2010 22:09:11 +0000 Subject: Fix PR2590 by making PatternSortingPredicate actually be ordered correctly. Previously it would get in trouble when two patterns were too similar and give them nondet ordering. We force this by using the record ID order as a fallback. The testsuite diff is due to alpha patterns being ordered slightly differently, the change is a semantic noop afaict: < lda $0,-100($16) --- > subq $16,100,$0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97509 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'utils/TableGen/DAGISelEmitter.cpp') 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; } }; } -- cgit v1.2.3