--- old/src/share/vm/opto/opaquenode.cpp 2014-11-07 22:46:15.564707002 +0100 +++ new/src/share/vm/opto/opaquenode.cpp 2014-11-07 22:46:15.371356409 +0100 @@ -23,13 +23,14 @@ */ #include "precompiled.hpp" +#include "opto/loopnode.hpp" #include "opto/opaquenode.hpp" #include "opto/phaseX.hpp" //============================================================================= // Do not allow value-numbering uint Opaque1Node::hash() const { return NO_HASH; } -uint Opaque1Node::cmp( const Node &n ) const { +uint Opaque1Node::cmp(const Node &n) const { return (&n == this); // Always fail except on self } @@ -40,10 +41,48 @@ // call to IterGVN and any chance of hitting this code. Hence there's no // phase-ordering problem with stripping Opaque1 in IGVN followed by some // more loop optimizations that require it. -Node *Opaque1Node::Identity( PhaseTransform *phase ) { +Node *Opaque1Node::Identity(PhaseTransform *phase) { return phase->C->major_progress() ? this : in(1); } +Node *Opaque1Node::Ideal(PhaseGVN *phase, bool can_reshape) { + if (!phase->C->major_progress() && outcnt() > 0) { + assert(can_reshape, "loop opts over but not IGVN?"); + if (raw_out(0)->Opcode() == Op_CmpI) { + Node* cmp = raw_out(0); + // If this opaque node feeds into the limit condition of a + // CountedLoop, we need to process the Phi node for the + // induction variable: the range of values taken by the Phi is + // known now and so its type is also known. + if (cmp->raw_out(0)->is_Bool()) { + Node* b = cmp->raw_out(0); + if (b->raw_out(0)->is_CountedLoopEnd()) { + CountedLoopEndNode* cle = b->raw_out(0)->as_CountedLoopEnd(); + if (cle->limit() == this) { + phase->is_IterGVN()->_worklist.push(cle->phi()); + } + } + } + Node* in1 = cmp->in(1); + for (uint i = 0; i < in1->outcnt(); i++) { + if (in1->raw_out(i)->Opcode() == Op_CastII) { + Node* castii = in1->raw_out(i); + if (castii->in(0) != NULL && castii->in(0)->in(0) != NULL && castii->in(0)->in(0)->is_If()) { + Node* ifnode = castii->in(0)->in(0); + if (ifnode->in(1) != NULL && ifnode->in(1)->in(1) == cmp) { + // Reprocess a CastII node that may depend on this + // opaque node value in case it's inexact and we can do + // a better job of setting its type. + phase->is_IterGVN()->_worklist.push(castii); + } + } + } + } + } + } + return NULL; +} + //============================================================================= // A node to prevent unwanted optimizations. Allows constant folding. Stops // value-numbering, most Ideal calls or Identity functions. This Node is