src/share/vm/opto/mulnode.cpp

changeset 994
7628781568e1
parent 993
3b5ac9e7e6ea
child 1059
337400e7a5dd
     1.1 --- a/src/share/vm/opto/mulnode.cpp	Mon Jan 26 16:22:12 2009 +0100
     1.2 +++ b/src/share/vm/opto/mulnode.cpp	Tue Feb 03 01:39:12 2009 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * Copyright 1997-2009 Sun Microsystems, Inc.  All Rights Reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -449,9 +449,10 @@
    1.11      // needed either.
    1.12      if( lop == Op_URShiftI ) {
    1.13        const TypeInt *t12 = phase->type( load->in(2) )->isa_int();
    1.14 -      if( t12 && t12->is_con() ) {
    1.15 -        int shift_con = t12->get_con();
    1.16 -        int mask = max_juint >> shift_con;
    1.17 +      if( t12 && t12->is_con() ) {  // Shift is by a constant
    1.18 +        int shift = t12->get_con();
    1.19 +        shift &= BitsPerJavaInteger - 1;  // semantics of Java shifts
    1.20 +        int mask = max_juint >> shift;
    1.21          if( (mask&con) == mask )  // If AND is useless, skip it
    1.22            return load;
    1.23        }
    1.24 @@ -579,9 +580,10 @@
    1.25      // needed either.
    1.26      if( lop == Op_URShiftL ) {
    1.27        const TypeInt *t12 = phase->type( usr->in(2) )->isa_int();
    1.28 -      if( t12 && t12->is_con() ) {
    1.29 -        int shift_con = t12->get_con();
    1.30 -        jlong mask = max_julong >> shift_con;
    1.31 +      if( t12 && t12->is_con() ) {  // Shift is by a constant
    1.32 +        int shift = t12->get_con();
    1.33 +        shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
    1.34 +        jlong mask = max_julong >> shift;
    1.35          if( (mask&con) == mask )  // If AND is useless, skip it
    1.36            return usr;
    1.37        }
    1.38 @@ -605,8 +607,8 @@
    1.39      const TypeInt *t12 = phase->type(rsh->in(2))->isa_int();
    1.40      if( t12 && t12->is_con() ) { // Shift is by a constant
    1.41        int shift = t12->get_con();
    1.42 -      shift &= (BitsPerJavaInteger*2)-1;  // semantics of Java shifts
    1.43 -      const jlong sign_bits_mask = ~(((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - shift)) -1);
    1.44 +      shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
    1.45 +      const jlong sign_bits_mask = ~(((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - shift)) -1);
    1.46        // If the AND'ing of the 2 masks has no bits, then only original shifted
    1.47        // bits survive.  NO sign-extension bits survive the maskings.
    1.48        if( (sign_bits_mask & mask) == 0 ) {
    1.49 @@ -786,7 +788,7 @@
    1.50  
    1.51    // Check for ((x & ((CONST64(1)<<(64-c0))-1)) << c0) which ANDs off high bits
    1.52    // before shifting them away.
    1.53 -  const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - con)) - CONST64(1);
    1.54 +  const jlong bits_mask = ((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) - CONST64(1);
    1.55    if( add1_op == Op_AndL &&
    1.56        phase->type(add1->in(2)) == TypeLong::make( bits_mask ) )
    1.57      return new (phase->C, 3) LShiftLNode( add1->in(1), in(2) );
    1.58 @@ -820,7 +822,7 @@
    1.59      return TypeLong::LONG;
    1.60  
    1.61    uint shift = r2->get_con();
    1.62 -  shift &= (BitsPerJavaInteger*2)-1;  // semantics of Java shifts
    1.63 +  shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
    1.64    // Shift by a multiple of 64 does nothing:
    1.65    if (shift == 0)  return t1;
    1.66  
    1.67 @@ -1235,7 +1237,7 @@
    1.68    if ( con == 0 ) return NULL;  // let Identity() handle a 0 shift count
    1.69                                // note: mask computation below does not work for 0 shift count
    1.70    // We'll be wanting the right-shift amount as a mask of that many bits
    1.71 -  const jlong mask = (((jlong)CONST64(1) << (jlong)(BitsPerJavaInteger*2 - con)) -1);
    1.72 +  const jlong mask = (((jlong)CONST64(1) << (jlong)(BitsPerJavaLong - con)) -1);
    1.73  
    1.74    // Check for ((x << z) + Y) >>> z.  Replace with x + con>>>z
    1.75    // The idiom for rounding to a power of 2 is "(Q+(2^z-1)) >>> z".
    1.76 @@ -1302,7 +1304,7 @@
    1.77  
    1.78    if (r2->is_con()) {
    1.79      uint shift = r2->get_con();
    1.80 -    shift &= (2*BitsPerJavaInteger)-1;  // semantics of Java shifts
    1.81 +    shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
    1.82      // Shift by a multiple of 64 does nothing:
    1.83      if (shift == 0)  return t1;
    1.84      // Calculate reasonably aggressive bounds for the result.
    1.85 @@ -1325,7 +1327,7 @@
    1.86      const TypeLong* tl = TypeLong::make(lo, hi, MAX2(r1->_widen,r2->_widen));
    1.87      #ifdef ASSERT
    1.88      // Make sure we get the sign-capture idiom correct.
    1.89 -    if (shift == (2*BitsPerJavaInteger)-1) {
    1.90 +    if (shift == BitsPerJavaLong - 1) {
    1.91        if (r1->_lo >= 0) assert(tl == TypeLong::ZERO, ">>>63 of + is 0");
    1.92        if (r1->_hi < 0)  assert(tl == TypeLong::ONE,  ">>>63 of - is +1");
    1.93      }

mercurial