Request for reviews (L): 6823354: Add intrinsics for{Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()

Christian Thalinger Christian.Thalinger at Sun.COM
Tue May 5 08:42:11 PDT 2009


On Tue, 2009-05-05 at 08:38 -0700, Vladimir Kozlov wrote:
> What problems do you have?
> Look on, for example, ConvL2INode::Value(). And your code:
> 
> const Type* CountLeadingZerosINode::Value( PhaseTransform *phase ) const {
>    const Type *t = phase->type( in(1) );
>    if( t == Type::TOP ) return Type::TOP;
>    const TypeInt *ti = t->isa_int();
>    if (ti && ti->is_con()) {
>      jint i = ti->get_con();
>      // HD, Figure 5-6
>      if (i == 0)
>        return TypeInt::make(BitsPerInt);
>      jint n = 1;
>      unsigned int x = i;
>      if (x >> 16 == 0) { n += 16; x <<= 16; }
>      if (x >> 24 == 0) { n +=  8; x <<=  8; }
>      if (x >> 28 == 0) { n +=  4; x <<=  4; }
>      if (x >> 30 == 0) { n +=  2; x <<=  2; }
>      n -= x >> 31;
>      return TypeInt::make(n);
>    }
>    return bottom_type();
> }

My current version returns TypeInt::INT if it's not a constant.  Is that
correct?  And if not, what's the difference between bottom_type() and
TypeInt::INT in this case?

-- Christian




More information about the hotspot-compiler-dev mailing list