src/hotspot/share/opto/subnode.cpp
changeset 51863 bc38c75eed57
parent 51666 7e6b86eb7914
child 52143 ad6384355aa3
equal deleted inserted replaced
51862:c319db69099c 51863:bc38c75eed57
  1520     const TypeInt* cmp1_in2 = phase->type(cmp1->in(2))->is_int();
  1520     const TypeInt* cmp1_in2 = phase->type(cmp1->in(2))->is_int();
  1521     Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),phase->intcon(-cmp1_in2->_hi)));
  1521     Node *ncmp = phase->transform( new CmpINode(cmp1->in(1),phase->intcon(-cmp1_in2->_hi)));
  1522     return new BoolNode( ncmp, _test._test );
  1522     return new BoolNode( ncmp, _test._test );
  1523   }
  1523   }
  1524 
  1524 
       
  1525   // Change "bool eq/ne (cmp (phi (X -X) 0))" into "bool eq/ne (cmp X 0)"
       
  1526   // since zero check of conditional negation of an integer is equal to
       
  1527   // zero check of the integer directly.
       
  1528   if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) &&
       
  1529       (cop == Op_CmpI) &&
       
  1530       (cmp2_type == TypeInt::ZERO) &&
       
  1531       (cmp1_op == Op_Phi)) {
       
  1532     // There should be a diamond phi with true path at index 1 or 2
       
  1533     PhiNode *phi = cmp1->as_Phi();
       
  1534     int idx_true = phi->is_diamond_phi();
       
  1535     if (idx_true != 0) {
       
  1536       // True input is in(idx_true) while false input is in(3 - idx_true)
       
  1537       Node *tin = phi->in(idx_true);
       
  1538       Node *fin = phi->in(3 - idx_true);
       
  1539       if ((tin->Opcode() == Op_SubI) &&
       
  1540           (phase->type(tin->in(1)) == TypeInt::ZERO) &&
       
  1541           (tin->in(2) == fin)) {
       
  1542         // Found conditional negation at true path, create a new CmpINode without that
       
  1543         Node *ncmp = phase->transform(new CmpINode(fin, cmp2));
       
  1544         return new BoolNode(ncmp, _test._test);
       
  1545       }
       
  1546       if ((fin->Opcode() == Op_SubI) &&
       
  1547           (phase->type(fin->in(1)) == TypeInt::ZERO) &&
       
  1548           (fin->in(2) == tin)) {
       
  1549         // Found conditional negation at false path, create a new CmpINode without that
       
  1550         Node *ncmp = phase->transform(new CmpINode(tin, cmp2));
       
  1551         return new BoolNode(ncmp, _test._test);
       
  1552       }
       
  1553     }
       
  1554   }
       
  1555 
  1525   // Change (-A vs 0) into (A vs 0) by commuting the test.  Disallow in the
  1556   // Change (-A vs 0) into (A vs 0) by commuting the test.  Disallow in the
  1526   // most general case because negating 0x80000000 does nothing.  Needed for
  1557   // most general case because negating 0x80000000 does nothing.  Needed for
  1527   // the CmpF3/SubI/CmpI idiom.
  1558   // the CmpF3/SubI/CmpI idiom.
  1528   if( cop == Op_CmpI &&
  1559   if( cop == Op_CmpI &&
  1529       cmp1_op == Op_SubI &&
  1560       cmp1_op == Op_SubI &&