< prev index next >
src/share/vm/opto/convertnode.cpp
Print this page
@@ -22,10 +22,11 @@
*
*/
#include "precompiled.hpp"
#include "opto/addnode.hpp"
+#include "opto/castnode.hpp"
#include "opto/convertnode.hpp"
#include "opto/matcher.hpp"
#include "opto/phaseX.hpp"
#include "opto/subnode.hpp"
#include "runtime/sharedRuntime.hpp"
@@ -291,11 +292,12 @@
}
}
}
#ifdef _LP64
- // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) ,
+ // Convert ConvI2L(AddI(x, y)) to AddL(ConvI2L(x), ConvI2L(y)) or
+ // ConvI2L(CastII(AddI(x, y))) to AddL(ConvI2L(CastII(x)), ConvI2L(CastII(y))),
// but only if x and y have subranges that cannot cause 32-bit overflow,
// under the assumption that x+y is in my own subrange this->type().
// This assumption is based on a constraint (i.e., type assertion)
// established in Parse::array_addressing or perhaps elsewhere.
@@ -315,10 +317,17 @@
// There's no common reason to "leak" a constant offset through the I2L.
// Addressing arithmetic will not absorb it as part of a 64-bit AddL.
Node* z = in(1);
int op = z->Opcode();
+ Node* ctrl = NULL;
+ if (op == Op_CastII && z->as_CastII()->has_range_check()) {
+ // Skip CastII node but save control dependency
+ ctrl = z->in(0);
+ z = z->in(1);
+ op = z->Opcode();
+ }
if (op == Op_AddI || op == Op_SubI) {
Node* x = z->in(1);
Node* y = z->in(2);
assert (x != z && y != z, "dead loop in ConvI2LNode::Ideal");
if (phase->type(x) == Type::TOP) return this_changed;
@@ -372,13 +381,14 @@
if (op == Op_SubI) {
jlong rylo0 = rylo;
rylo = -ryhi;
ryhi = -rylo0;
}
-
- Node* cx = phase->transform( new ConvI2LNode(x, TypeLong::make(rxlo, rxhi, widen)) );
- Node* cy = phase->transform( new ConvI2LNode(y, TypeLong::make(rylo, ryhi, widen)) );
+ assert(rxlo == (int)rxlo && rxhi == (int)rxhi, "x should not overflow");
+ assert(rylo == (int)rylo && ryhi == (int)ryhi, "y should not overflow");
+ Node* cx = phase->C->constrained_convI2L(phase, x, TypeInt::make(rxlo, rxhi, widen), ctrl);
+ Node* cy = phase->C->constrained_convI2L(phase, y, TypeInt::make(rylo, ryhi, widen), ctrl);
switch (op) {
case Op_AddI: return new AddLNode(cx, cy);
case Op_SubI: return new SubLNode(cx, cy);
default: ShouldNotReachHere();
}
< prev index next >