1.1 --- a/src/share/vm/opto/connode.cpp Tue May 05 11:02:10 2009 -0700 1.2 +++ b/src/share/vm/opto/connode.cpp Wed May 06 00:27:52 2009 -0700 1.3 @@ -1255,3 +1255,93 @@ 1.4 v.set_jdouble(td->getd()); 1.5 return TypeLong::make( v.get_jlong() ); 1.6 } 1.7 + 1.8 +//------------------------------Value------------------------------------------ 1.9 +const Type* CountLeadingZerosINode::Value(PhaseTransform* phase) const { 1.10 + const Type* t = phase->type(in(1)); 1.11 + if (t == Type::TOP) return Type::TOP; 1.12 + const TypeInt* ti = t->isa_int(); 1.13 + if (ti && ti->is_con()) { 1.14 + jint i = ti->get_con(); 1.15 + // HD, Figure 5-6 1.16 + if (i == 0) 1.17 + return TypeInt::make(BitsPerInt); 1.18 + int n = 1; 1.19 + unsigned int x = i; 1.20 + if (x >> 16 == 0) { n += 16; x <<= 16; } 1.21 + if (x >> 24 == 0) { n += 8; x <<= 8; } 1.22 + if (x >> 28 == 0) { n += 4; x <<= 4; } 1.23 + if (x >> 30 == 0) { n += 2; x <<= 2; } 1.24 + n -= x >> 31; 1.25 + return TypeInt::make(n); 1.26 + } 1.27 + return TypeInt::INT; 1.28 +} 1.29 + 1.30 +//------------------------------Value------------------------------------------ 1.31 +const Type* CountLeadingZerosLNode::Value(PhaseTransform* phase) const { 1.32 + const Type* t = phase->type(in(1)); 1.33 + if (t == Type::TOP) return Type::TOP; 1.34 + const TypeLong* tl = t->isa_long(); 1.35 + if (tl && tl->is_con()) { 1.36 + jlong l = tl->get_con(); 1.37 + // HD, Figure 5-6 1.38 + if (l == 0) 1.39 + return TypeInt::make(BitsPerLong); 1.40 + int n = 1; 1.41 + unsigned int x = (((julong) l) >> 32); 1.42 + if (x == 0) { n += 32; x = (int) l; } 1.43 + if (x >> 16 == 0) { n += 16; x <<= 16; } 1.44 + if (x >> 24 == 0) { n += 8; x <<= 8; } 1.45 + if (x >> 28 == 0) { n += 4; x <<= 4; } 1.46 + if (x >> 30 == 0) { n += 2; x <<= 2; } 1.47 + n -= x >> 31; 1.48 + return TypeInt::make(n); 1.49 + } 1.50 + return TypeInt::INT; 1.51 +} 1.52 + 1.53 +//------------------------------Value------------------------------------------ 1.54 +const Type* CountTrailingZerosINode::Value(PhaseTransform* phase) const { 1.55 + const Type* t = phase->type(in(1)); 1.56 + if (t == Type::TOP) return Type::TOP; 1.57 + const TypeInt* ti = t->isa_int(); 1.58 + if (ti && ti->is_con()) { 1.59 + jint i = ti->get_con(); 1.60 + // HD, Figure 5-14 1.61 + int y; 1.62 + if (i == 0) 1.63 + return TypeInt::make(BitsPerInt); 1.64 + int n = 31; 1.65 + y = i << 16; if (y != 0) { n = n - 16; i = y; } 1.66 + y = i << 8; if (y != 0) { n = n - 8; i = y; } 1.67 + y = i << 4; if (y != 0) { n = n - 4; i = y; } 1.68 + y = i << 2; if (y != 0) { n = n - 2; i = y; } 1.69 + y = i << 1; if (y != 0) { n = n - 1; } 1.70 + return TypeInt::make(n); 1.71 + } 1.72 + return TypeInt::INT; 1.73 +} 1.74 + 1.75 +//------------------------------Value------------------------------------------ 1.76 +const Type* CountTrailingZerosLNode::Value(PhaseTransform* phase) const { 1.77 + const Type* t = phase->type(in(1)); 1.78 + if (t == Type::TOP) return Type::TOP; 1.79 + const TypeLong* tl = t->isa_long(); 1.80 + if (tl && tl->is_con()) { 1.81 + jlong l = tl->get_con(); 1.82 + // HD, Figure 5-14 1.83 + int x, y; 1.84 + if (l == 0) 1.85 + return TypeInt::make(BitsPerLong); 1.86 + int n = 63; 1.87 + y = (int) l; if (y != 0) { n = n - 32; x = y; } else x = (((julong) l) >> 32); 1.88 + y = x << 16; if (y != 0) { n = n - 16; x = y; } 1.89 + y = x << 8; if (y != 0) { n = n - 8; x = y; } 1.90 + y = x << 4; if (y != 0) { n = n - 4; x = y; } 1.91 + y = x << 2; if (y != 0) { n = n - 2; x = y; } 1.92 + y = x << 1; if (y != 0) { n = n - 1; } 1.93 + return TypeInt::make(n); 1.94 + } 1.95 + return TypeInt::INT; 1.96 +}