Index: src/ResolvExpr/Cost.h
===================================================================
--- src/ResolvExpr/Cost.h	(revision 9795142ef4d80a748b505ad7598a4f762f0055d8)
+++ src/ResolvExpr/Cost.h	(revision b10c39a0eabbc4a5be7be30e5a79480917e65b87)
@@ -10,6 +10,6 @@
 // Created On       : Sun May 17 09:39:50 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Sun Apr 28 18:26:36 2019
-// Update Count     : 29
+// Last Modified On : Mon Apr 29 18:33:44 2019
+// Update Count     : 49
 //
 
@@ -18,4 +18,5 @@
 #include <iostream>
 #include <cassert>
+#include <climits>
 
 namespace ResolvExpr {
@@ -216,7 +217,11 @@
 		          << cost.referenceCost << " )";
 	}
-#endif // 0
+
+#else
 
 	//*************************** NEW ***************************
+
+	// To maximize performance and space, the 7 resolution costs are packed into a single 64-bit word. However, the
+	// specialization cost is a negative value so a correction is needed is a few places.
 
 	class Cost {
@@ -234,23 +239,24 @@
 				unsigned char unsafeCost;				///< Unsafe (narrowing) conversions
 			#else
-				#error BIG_ENDIAN unsupported
+				#error Cost BIG_ENDIAN unsupported
 			#endif
 			} v;
 			uint64_t all;
 		};
+		static const unsigned char correctb = 0xff;		// byte correction for negative spec cost
+		static const uint64_t correctw = 0x00'00'00'00'00'ff'00'00; //' word correction for negative spec cost
 	  public:
 		// Compiler adjusts constants for correct endian.
 		enum : uint64_t {
-			zero       = 0x00'00'00'00'00'ff'00'00,
-			infinity   = 0xff'ff'ff'ff'ff'00'ff'ff,
-			correction = 0x00'00'00'00'00'ff'00'00,		// correct for negative spec cost
-			unsafe     = 0x01'00'00'00'00'ff'00'00,
-			poly       = 0x00'01'00'00'00'ff'00'00,
-			safe       = 0x00'00'01'00'00'ff'00'00,
-			sign       = 0x00'00'00'01'00'ff'00'00,
-			var        = 0x00'00'00'00'01'ff'00'00,
-			spec       = 0x00'00'00'00'00'fe'00'00,
-			reference  = 0x00'00'00'00'00'ff'01'00,
-		}; //
+			zero      = 0x00'00'00'00'00'ff'00'00,
+			infinity  = 0xff'ff'ff'ff'ff'00'ff'ff,
+			unsafe    = 0x01'00'00'00'00'ff'00'00,
+			poly      = 0x00'01'00'00'00'ff'00'00,
+			safe      = 0x00'00'01'00'00'ff'00'00,
+			sign      = 0x00'00'00'01'00'ff'00'00,
+			var       = 0x00'00'00'00'01'ff'00'00,
+			spec      = 0x00'00'00'00'00'fe'00'00,
+			reference = 0x00'00'00'00'00'ff'01'00,
+		}; //'
 
 		Cost( uint64_t all ) { Cost::all = all; }
@@ -258,12 +264,16 @@
 			// Assume little-endian => first value is low priority and last is high priority.
 			v = {
+			#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 				(unsigned char)0,						// padding
-				(unsigned char)referenceCost, 
-				(unsigned char)(specCost + 0xff ),		// correct for signedness
+				(unsigned char)referenceCost,			// low priority
+				(unsigned char)(specCost + correctb),	// correct for signedness
 				(unsigned char)varCost, 
 				(unsigned char)signCost, 
 				(unsigned char)safeCost, 
 				(unsigned char)polyCost, 
-				(unsigned char)unsafeCost, 
+				(unsigned char)unsafeCost, 				// high priority
+			#else
+				#error Cost BIG_ENDIAN unsupported
+			#endif
 			};
 		}
@@ -274,5 +284,5 @@
 		int get_signCost() const { return v.signCost; }
 		int get_varCost() const { return v.varCost; }
-		int get_specCost() const { return -(0xff - v.specCost); }
+		int get_specCost() const { return -(correctb - v.specCost); }
 		int get_referenceCost() const { return v.referenceCost; }
 
@@ -295,40 +305,40 @@
 				return *this;
 			}
-			all += rhs.all - correction;				// correct for negative spec cost
+			all += rhs.all - correctw;					// correct for negative spec cost
 			return *this;
 		}
 
 		Cost incUnsafe( int inc = 1 ) {
-			if ( all != infinity ) { assert( v.unsafeCost + inc < 256 ); v.unsafeCost += inc; }
+			if ( all != infinity ) { assert( v.unsafeCost + inc <= UCHAR_MAX ); v.unsafeCost += inc; }
 			return *this;
 		}
 
 		Cost incPoly( int inc = 1 ) {
-			if ( all != infinity ) { assert( v.polyCost + inc < 256 ); v.polyCost += inc; }
+			if ( all != infinity ) { assert( v.polyCost + inc <= UCHAR_MAX ); v.polyCost += inc; }
 			return *this;
 		}
 
 		Cost incSafe( int inc = 1 ) {
-			if ( all != infinity ) { assert( v.safeCost + inc < 256 ); v.safeCost += inc; }
+			if ( all != infinity ) { assert( v.safeCost + inc <= UCHAR_MAX ); v.safeCost += inc; }
 			return *this;
 		}
 
 		Cost incSign( int inc = 1 ) {
-			if ( all != infinity ) { assert( v.signCost + inc < 256 ); v.signCost += inc; }
+			if ( all != infinity ) { assert( v.signCost + inc <= UCHAR_MAX ); v.signCost += inc; }
 			return *this;
 		}
 
 		Cost incVar( int inc = 1 ) {
-			if ( all != infinity ) { assert( v.varCost + inc < 256 ); v.varCost += inc; }
+			if ( all != infinity ) { assert( v.varCost + inc <= UCHAR_MAX ); v.varCost += inc; }
 			return *this;
 		}
 
 		Cost decSpec( int dec = 1 ) {
-			if ( all != infinity ) { v.specCost -= dec; }
+			if ( all != infinity ) { assert( v.specCost - dec >= 0 ); v.specCost -= dec; }
 			return *this;
 		}
 
 		Cost incReference( int inc = 1 ) {
-			if ( all != infinity ) { assert( v.referenceCost + inc < 256 ); v.referenceCost += inc; }
+			if ( all != infinity ) { assert( v.referenceCost + inc <= UCHAR_MAX ); v.referenceCost += inc; }
 			return *this;
 		}
@@ -353,5 +363,5 @@
 	inline Cost operator+( const Cost lhs, const Cost rhs ) {
 		if ( lhs.all == Cost::infinity || rhs.all == Cost::infinity ) return Cost{ Cost::infinity };
-		return Cost{ lhs.all + rhs.all - Cost::correction }; // correct for negative spec cost
+		return Cost{ lhs.all + rhs.all - Cost::correctw }; // correct for negative spec cost
 	}
 
@@ -361,4 +371,5 @@
 				  << ", " << cost.get_referenceCost() << " )";
 	}
+#endif // 0
 } // namespace ResolvExpr
 
