@@ -216,22 +216,19 @@ Node *AddNode::Ideal(PhaseGVN *phase, bool can_reshape) {
216
216
// the other input's symbols.
217
217
const Type* AddNode::Value (PhaseGVN* phase) const {
218
218
// 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
+ }
229
224
230
225
// 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
+ }
233
230
234
- return add_ring (t1,t2); // Local flavor of type addition
231
+ return add_ring (t1, t2); // Local flavor of type addition
235
232
}
236
233
237
234
// ------------------------------add_identity-----------------------------------
@@ -513,7 +510,9 @@ const Type *AddFNode::add_of_identity( const Type *t1, const Type *t2 ) const {
513
510
// This also type-checks the inputs for sanity. Guaranteed never to
514
511
// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
515
512
const 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
+ }
517
516
return TypeF::make ( t0->getf () + t1->getf () );
518
517
}
519
518
@@ -544,7 +543,9 @@ const Type *AddDNode::add_of_identity( const Type *t1, const Type *t2 ) const {
544
543
// This also type-checks the inputs for sanity. Guaranteed never to
545
544
// be passed a TOP or BOTTOM type, these are filtered out by pre-check.
546
545
const 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
+ }
548
549
return TypeD::make ( t0->getd () + t1->getd () );
549
550
}
550
551
@@ -1367,9 +1368,12 @@ Node* MinLNode::Ideal(PhaseGVN* phase, bool can_reshape) {
1367
1368
}
1368
1369
1369
1370
// ------------------------------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
+ }
1373
1377
1374
1378
if (r0->is_nan ()) {
1375
1379
return r0;
@@ -1389,9 +1393,12 @@ const Type *MinFNode::add_ring( const Type *t0, const Type *t1 ) const {
1389
1393
}
1390
1394
1391
1395
// ------------------------------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
+ }
1395
1402
1396
1403
if (r0->is_nan ()) {
1397
1404
return r0;
@@ -1411,9 +1418,12 @@ const Type *MinDNode::add_ring( const Type *t0, const Type *t1 ) const {
1411
1418
}
1412
1419
1413
1420
// ------------------------------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
+ }
1417
1427
1418
1428
if (r0->is_nan ()) {
1419
1429
return r0;
@@ -1433,9 +1443,12 @@ const Type *MaxFNode::add_ring( const Type *t0, const Type *t1 ) const {
1433
1443
}
1434
1444
1435
1445
// ------------------------------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
+ }
1439
1452
1440
1453
if (r0->is_nan ()) {
1441
1454
return r0;
0 commit comments