@@ -216,22 +216,19 @@ Node *AddNode::Ideal(PhaseGVN *phase, bool can_reshape) {
216216// the other input's symbols.
217217const Type* AddNode::Value (PhaseGVN* phase) const {
218218 // Either input is TOP ==> the result is TOP
219- const Type *t1 = phase->type ( in (1 ) );
220- const Type *t2 = phase->type ( in (2 ) );
221- if ( t1 == Type::TOP ) return Type::TOP;
222- if ( t2 == Type::TOP ) return Type::TOP;
223-
224- // Either input is BOTTOM ==> the result is the local BOTTOM
225- const Type *bot = bottom_type ();
226- if ( (t1 == bot) || (t2 == bot) ||
227- (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
228- return bot;
219+ const Type* t1 = phase->type (in (1 ));
220+ const Type* t2 = phase->type (in (2 ));
221+ if (t1 == Type::TOP || t2 == Type::TOP) {
222+ return Type::TOP;
223+ }
229224
230225 // Check for an addition involving the additive identity
231- const Type *tadd = add_of_identity ( t1, t2 );
232- if ( tadd ) return tadd;
226+ const Type* tadd = add_of_identity (t1, t2);
227+ if (tadd != nullptr ) {
228+ return tadd;
229+ }
233230
234- return add_ring (t1,t2); // Local flavor of type addition
231+ return add_ring (t1, t2); // Local flavor of type addition
235232}
236233
237234// ------------------------------add_identity-----------------------------------
@@ -513,7 +510,9 @@ const Type *AddFNode::add_of_identity( const Type *t1, const Type *t2 ) const {
513510// This also type-checks the inputs for sanity. Guaranteed never to
514511// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
515512const Type *AddFNode::add_ring ( const Type *t0, const Type *t1 ) const {
516- // We must be adding 2 float constants.
513+ if (!t0->isa_float_constant () || !t1->isa_float_constant ()) {
514+ return bottom_type ();
515+ }
517516 return TypeF::make ( t0->getf () + t1->getf () );
518517}
519518
@@ -544,7 +543,9 @@ const Type *AddDNode::add_of_identity( const Type *t1, const Type *t2 ) const {
544543// This also type-checks the inputs for sanity. Guaranteed never to
545544// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
546545const Type *AddDNode::add_ring ( const Type *t0, const Type *t1 ) const {
547- // We must be adding 2 double constants.
546+ if (!t0->isa_double_constant () || !t1->isa_double_constant ()) {
547+ return bottom_type ();
548+ }
548549 return TypeD::make ( t0->getd () + t1->getd () );
549550}
550551
@@ -1367,9 +1368,12 @@ Node* MinLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
13671368}
13681369
13691370// ------------------------------add_ring---------------------------------------
1370- const Type *MinFNode::add_ring ( const Type *t0, const Type *t1 ) const {
1371- const TypeF *r0 = t0->is_float_constant ();
1372- const TypeF *r1 = t1->is_float_constant ();
1371+ const Type* MinFNode::add_ring (const Type* t0, const Type* t1 ) const {
1372+ const TypeF* r0 = t0->isa_float_constant ();
1373+ const TypeF* r1 = t1->isa_float_constant ();
1374+ if (r0 == nullptr || r1 == nullptr ) {
1375+ return bottom_type ();
1376+ }
13731377
13741378 if (r0->is_nan ()) {
13751379 return r0;
@@ -1389,9 +1393,12 @@ const Type *MinFNode::add_ring( const Type *t0, const Type *t1 ) const {
13891393}
13901394
13911395// ------------------------------add_ring---------------------------------------
1392- const Type *MinDNode::add_ring ( const Type *t0, const Type *t1 ) const {
1393- const TypeD *r0 = t0->is_double_constant ();
1394- const TypeD *r1 = t1->is_double_constant ();
1396+ const Type* MinDNode::add_ring (const Type* t0, const Type* t1) const {
1397+ const TypeD* r0 = t0->isa_double_constant ();
1398+ const TypeD* r1 = t1->isa_double_constant ();
1399+ if (r0 == nullptr || r1 == nullptr ) {
1400+ return bottom_type ();
1401+ }
13951402
13961403 if (r0->is_nan ()) {
13971404 return r0;
@@ -1411,9 +1418,12 @@ const Type *MinDNode::add_ring( const Type *t0, const Type *t1 ) const {
14111418}
14121419
14131420// ------------------------------add_ring---------------------------------------
1414- const Type *MaxFNode::add_ring ( const Type *t0, const Type *t1 ) const {
1415- const TypeF *r0 = t0->is_float_constant ();
1416- const TypeF *r1 = t1->is_float_constant ();
1421+ const Type* MaxFNode::add_ring (const Type* t0, const Type* t1) const {
1422+ const TypeF* r0 = t0->isa_float_constant ();
1423+ const TypeF* r1 = t1->isa_float_constant ();
1424+ if (r0 == nullptr || r1 == nullptr ) {
1425+ return bottom_type ();
1426+ }
14171427
14181428 if (r0->is_nan ()) {
14191429 return r0;
@@ -1433,9 +1443,12 @@ const Type *MaxFNode::add_ring( const Type *t0, const Type *t1 ) const {
14331443}
14341444
14351445// ------------------------------add_ring---------------------------------------
1436- const Type *MaxDNode::add_ring ( const Type *t0, const Type *t1 ) const {
1437- const TypeD *r0 = t0->is_double_constant ();
1438- const TypeD *r1 = t1->is_double_constant ();
1446+ const Type* MaxDNode::add_ring (const Type* t0, const Type* t1) const {
1447+ const TypeD* r0 = t0->isa_double_constant ();
1448+ const TypeD* r1 = t1->isa_double_constant ();
1449+ if (r0 == nullptr || r1 == nullptr ) {
1450+ return bottom_type ();
1451+ }
14391452
14401453 if (r0->is_nan ()) {
14411454 return r0;
0 commit comments