[test-suite] r178547 - Increasing stability of sort in Burg

Renato Golin renato.golin at linaro.org
Tue Apr 2 09:15:24 PDT 2013


Author: rengolin
Date: Tue Apr  2 11:15:23 2013
New Revision: 178547

URL: http://llvm.org/viewvc/llvm-project?rev=178547&view=rev
Log:
Increasing stability of sort in Burg

The state matrix was being generated slightly different
on x86_64 and ARM Linux than on the reference output because
the sort wasn't stable. This new version tries to stabilize
the comparison, but since the structures are big and nested,
there is room for further improvement, if needed.

Modified:
    test-suite/trunk/MultiSource/Applications/Burg/burg.reference_output
    test-suite/trunk/MultiSource/Applications/Burg/plank.c

Modified: test-suite/trunk/MultiSource/Applications/Burg/burg.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/Burg/burg.reference_output?rev=178547&r1=178546&r2=178547&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Applications/Burg/burg.reference_output (original)
+++ test-suite/trunk/MultiSource/Applications/Burg/burg.reference_output Tue Apr  2 11:15:23 2013
@@ -64,16 +64,16 @@ static struct {
 	unsigned int f7:2;
 } burm_plank_0[] = {
 	{   0,   0,   0,   0,   0,   0,   0,   0,},	/* row 0 */
-	{   0,   1,   0,   0,   1,   0,   0,   1,},	/* row 1 */
-	{   1,   0,   0,   1,   0,   3,   1,   0,},	/* row 2 */
-	{   0,   1,   0,   0,   1,   0,   0,   2,},	/* row 3 */
-	{   1,   0,   1,   1,   0,   3,   2,   0,},	/* row 4 */
+	{   0,   1,   0,   0,   1,   0,   0,   2,},	/* row 1 */
+	{   1,   0,   0,   1,   0,   1,   1,   0,},	/* row 2 */
+	{   0,   1,   0,   0,   1,   0,   0,   1,},	/* row 3 */
+	{   1,   0,   1,   1,   0,   1,   2,   0,},	/* row 4 */
 	{   0,   0,   0,   0,   2,   0,   0,   0,},	/* row 5 */
-	{   1,   0,   0,   0,   0,   1,   0,   0,},	/* row 6 */
-	{   1,   0,   0,   0,   0,   2,   0,   0,},	/* row 7 */
+	{   1,   0,   0,   0,   0,   2,   0,   0,},	/* row 6 */
+	{   1,   0,   0,   0,   0,   3,   0,   0,},	/* row 7 */
 };
 static short burm_eruleMap[] = {
-    0,    4,    5,    3,    0,    1,    2,    0,    7,    6
+    0,    3,    4,    5,    0,    1,    2,    0,    6,    7
 };
 #define burm_reg_rule(state)	burm_eruleMap[burm_plank_0[state].f7 +7]
 #define burm_con_rule(state)	burm_eruleMap[burm_plank_0[state].f6 +4]

Modified: test-suite/trunk/MultiSource/Applications/Burg/plank.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/Burg/plank.c?rev=178547&r1=178546&r2=178547&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Applications/Burg/plank.c (original)
+++ test-suite/trunk/MultiSource/Applications/Burg/plank.c Tue Apr  2 11:15:23 2013
@@ -186,13 +186,25 @@ assignRules(ast) RuleAST ast;
 static int
 stateCompare(s, t) Item_Set *s; Item_Set *t;
 {
-	return strcmp((*s)->op->name, (*t)->op->name);
+	int res = 0;
+	if ((res = strcmp((*s)->op->name, (*t)->op->name)) != 0)
+		return res;
+	if ((*s)->num < (*t)->num) return -1;
+	if ((*s)->num > (*t)->num) return 1;
+	if ((*s)->newNum < (*t)->newNum) return -1;
+	if ((*s)->newNum > (*t)->newNum) return 1;
+	return 0;
 }
 
 static int
 ruleCompare(s, t) RuleAST *s; RuleAST *t;
 {
-	return strcmp((*s)->lhs, (*t)->lhs);
+	int res = 0;
+	if ((res = strcmp((*s)->lhs, (*t)->lhs)) != 0)
+		return res;
+	if ((*s)->erulenum < (*t)->erulenum) return -1;
+	if ((*s)->erulenum > (*t)->erulenum) return 1;
+	return 0;
 }
 
 void





More information about the llvm-commits mailing list