diff --git a/mach/i86/cg/mach.c b/mach/i86/cg/mach.c
index 8bd0d2bbb..8956fb957 100644
--- a/mach/i86/cg/mach.c
+++ b/mach/i86/cg/mach.c
@@ -89,8 +89,8 @@ regscore(off, size, typ, score, totyp)
 {
 	if (size != 2) return -1;
 	score -= 1;
-	if (typ == reg_pointer || typ == reg_loop) score *= 3;
-	else score *= 2;
+	score += score;
+	if (typ == reg_pointer || typ == reg_loop) score += (score >> 2);
 	score -= 2;	/* cost of saving */
 	if (off >= 0) score -= 3;
 	return score;
diff --git a/mach/i86/cg/table b/mach/i86/cg/table
index fc88fe670..c2438b0db 100644
--- a/mach/i86/cg/table
+++ b/mach/i86/cg/table
@@ -1849,16 +1849,48 @@ lar !defined($1) | |	remove(ALL)
  * group 12 : Compare instructions	*
  ****************************************/
 
-cmi $1==2	| |	|				    | sbi 2  |
-cmi $1==4	| rmorconst rmorconst X_REG X_REG |
-			"sub %[3],%[1]"
-			"sbb %[4],%[2]"
-			"jne 1f"
-			"and %[3],%[3]"
-			"je 1f"
-			"inc %[4]\n1: "
-			setcc(%[4]) erase(%[3]) erase(%[4])
-						     | %[4] | |
+cmi $1==2	| NO register rmorconst |
+			allocate(REG = {ANYCON,0})
+			"cmp %[1],%[2]"
+			"je 2f"
+			"jl 1f"
+			"inc %[a]"
+			"jmp 2f"
+			"1:\tdec %[a]\n2:"
+			setcc(%[a])
+			erase(%[a])		     | %[a] | |(4,4)
+...	       | rmorconst register |
+			allocate(REG = {ANYCON,0})
+			"cmp %[1],%[2]"
+			"je 2f"
+			"jl 1f"
+			"inc %[a]"
+			"jmp 2f"
+			"1:\tdec %[a]\n2:"
+			setcc(%[a])
+			erase(%[a])		     | %[a] | |(4,4)
+...	       | ACC const |
+			allocate(REG = {ANYCON,0})
+			"cmp %[1],%[2]"
+			"je 2f"
+			"jl 1f"
+			"inc %[a]"
+			"jmp 2f"
+			"1:\tdec %[a]\n2:"
+			setcc(%[a])
+			erase(%[a])		     | %[a] | |(3,4)
+...	       | const ACC |
+			allocate(REG = {ANYCON,0})
+			"cmp %[1],%[2]"
+			"je 2f"
+			"jl 1f"
+			"inc %[a]"
+			"jmp 2f"
+			"1:\tdec %[a]\n2:"
+			setcc(%[a])
+			erase(%[a])		     | %[a] | |(3,4)
+cmi $1==4	| |	remove(ALL)
+			"call .cmi4"			| ax | |
 cmu $1==2	| |	|				    | cmp |
 cmu $1==4	| |	remove(ALL)
 			"call .cmu4"		       | ax | |
@@ -2273,6 +2305,39 @@ cms zne $1==2	| regorconst rm STACK |
 			remove(ALL)
 			"cmp %[1],%[2]"
 			"jne $2" 			  | | |
+ldc cmi zlt highw(1)==0 && loww(1)==0 && $2==4 | rmorconst rmorconst |
+                                        | %[2] | zlt $3 |
+ldc cmi zge highw(1)==0 && loww(1)==0 && $2==4 | rmorconst rmorconst |
+                                        | %[2] | zge $3 |
+ldc cms zeq $2==4 && loww(1)==0 && highw(1)==0 | rmorconst X_REG |
+                        remove(ALL)
+                        "or %[2],%[1]"
+                        "je $3"                        |               | |
+...						| X_REG rmorconst |
+			remove(ALL)
+			"or %[1],%[2]"
+			"je $3"			|		| |
+ldc cms zne $2==4 && loww(1)==0 && highw(1)==0 | rmorconst X_REG |
+                        remove(ALL)
+                        "or %[2],%[1]"
+                        "jne $3"                        |               | |
+...						| X_REG rmorconst |
+			remove(ALL)
+			"or %[1],%[2]"
+			"jne $3"			|		| |
+ldc cms zeq $2==4       | rmorconst rmorconst |
+                        remove(ALL)
+                        "cmp %[2],%(loww(1)%)"
+                        "jne 1f"
+                        "cmp %[1],%(highw(1)%)"
+                        "je $3"
+                        "1:"                            |               | |
+ldc cms zne $2==4       | rmorconst rmorconst |
+                        remove(ALL)
+                        "cmp %[2],%(loww(1)%)"
+                        "jne $3"
+                        "cmp %[1],%(highw(1)%)"
+                        "jne $3"                        |               | |
 cms zne $1==4	| regorconst regorconst rm rm STACK |
 			"cmp %[3],%[1]"
 			"jne $2"