< prev index next >

src/hotspot/share/opto/divnode.cpp

Print this page

1588     const Type* divisor_type = phase->type(divisor());
1589     if (dividend_type == Type::TOP || divisor_type == Type::TOP) {
1590       return phase->C->top();
1591     }
1592     const Type* constant_result = get_result_if_constant(dividend_type, divisor_type);
1593     if (constant_result != nullptr) {
1594       return make_tuple_of_input_state_and_constant_result(igvn, constant_result);
1595     }
1596   }
1597 
1598   return CallLeafPureNode::Ideal(phase, can_reshape);
1599 }
1600 
1601 /* Give a tuple node for ::Ideal to return, made of the input state (control to return addr)
1602  * and the given constant result. Idealization of projections will make sure to transparently
1603  * propagate the input state and replace the result by the said constant.
1604  */
1605 TupleNode* ModFloatingNode::make_tuple_of_input_state_and_constant_result(PhaseIterGVN* phase, const Type* con) const {
1606   Node* con_node = phase->makecon(con);
1607   TupleNode* tuple = TupleNode::make(
1608       tf()->range(),
1609       in(TypeFunc::Control),
1610       in(TypeFunc::I_O),
1611       in(TypeFunc::Memory),
1612       in(TypeFunc::FramePtr),
1613       in(TypeFunc::ReturnAdr),
1614       con_node);
1615 
1616   return tuple;
1617 }
1618 
1619 //=============================================================================
1620 
1621 DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) {
1622   init_req(0, c);
1623   init_req(1, dividend);
1624   init_req(2, divisor);
1625 }
1626 
1627 DivModNode* DivModNode::make(Node* div_or_mod, BasicType bt, bool is_unsigned) {
1628   assert(bt == T_INT || bt == T_LONG, "only int or long input pattern accepted");

1651   DivModINode* divmod = new DivModINode(n->in(0), n->in(1), n->in(2));
1652   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1653   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1654   return divmod;
1655 }
1656 
1657 //------------------------------make------------------------------------------
1658 DivModLNode* DivModLNode::make(Node* div_or_mod) {
1659   Node* n = div_or_mod;
1660   assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL,
1661          "only div or mod input pattern accepted");
1662 
1663   DivModLNode* divmod = new DivModLNode(n->in(0), n->in(1), n->in(2));
1664   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1665   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1666   return divmod;
1667 }
1668 
1669 //------------------------------match------------------------------------------
1670 // return result(s) along with their RegMask info
1671 Node *DivModINode::match( const ProjNode *proj, const Matcher *match ) {
1672   uint ideal_reg = proj->ideal_reg();
1673   RegMask rm;
1674   if (proj->_con == div_proj_num) {
1675     rm = match->divI_proj_mask();
1676   } else {
1677     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1678     rm = match->modI_proj_mask();
1679   }
1680   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1681 }
1682 
1683 
1684 //------------------------------match------------------------------------------
1685 // return result(s) along with their RegMask info
1686 Node *DivModLNode::match( const ProjNode *proj, const Matcher *match ) {
1687   uint ideal_reg = proj->ideal_reg();
1688   RegMask rm;
1689   if (proj->_con == div_proj_num) {
1690     rm = match->divL_proj_mask();
1691   } else {
1692     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1693     rm = match->modL_proj_mask();
1694   }
1695   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1696 }
1697 
1698 //------------------------------make------------------------------------------
1699 UDivModINode* UDivModINode::make(Node* div_or_mod) {
1700   Node* n = div_or_mod;
1701   assert(n->Opcode() == Op_UDivI || n->Opcode() == Op_UModI,
1702          "only div or mod input pattern accepted");
1703 
1704   UDivModINode* divmod = new UDivModINode(n->in(0), n->in(1), n->in(2));
1705   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1706   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1707   return divmod;
1708 }
1709 
1710 //------------------------------make------------------------------------------
1711 UDivModLNode* UDivModLNode::make(Node* div_or_mod) {
1712   Node* n = div_or_mod;
1713   assert(n->Opcode() == Op_UDivL || n->Opcode() == Op_UModL,
1714          "only div or mod input pattern accepted");
1715 
1716   UDivModLNode* divmod = new UDivModLNode(n->in(0), n->in(1), n->in(2));
1717   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1718   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1719   return divmod;
1720 }
1721 
1722 //------------------------------match------------------------------------------
1723 // return result(s) along with their RegMask info
1724 Node* UDivModINode::match( const ProjNode *proj, const Matcher *match ) {
1725   uint ideal_reg = proj->ideal_reg();
1726   RegMask rm;
1727   if (proj->_con == div_proj_num) {
1728     rm = match->divI_proj_mask();
1729   } else {
1730     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1731     rm = match->modI_proj_mask();
1732   }
1733   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1734 }
1735 
1736 
1737 //------------------------------match------------------------------------------
1738 // return result(s) along with their RegMask info
1739 Node* UDivModLNode::match( const ProjNode *proj, const Matcher *match ) {
1740   uint ideal_reg = proj->ideal_reg();
1741   RegMask rm;
1742   if (proj->_con == div_proj_num) {
1743     rm = match->divL_proj_mask();
1744   } else {
1745     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1746     rm = match->modL_proj_mask();
1747   }
1748   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1749 }

1588     const Type* divisor_type = phase->type(divisor());
1589     if (dividend_type == Type::TOP || divisor_type == Type::TOP) {
1590       return phase->C->top();
1591     }
1592     const Type* constant_result = get_result_if_constant(dividend_type, divisor_type);
1593     if (constant_result != nullptr) {
1594       return make_tuple_of_input_state_and_constant_result(igvn, constant_result);
1595     }
1596   }
1597 
1598   return CallLeafPureNode::Ideal(phase, can_reshape);
1599 }
1600 
1601 /* Give a tuple node for ::Ideal to return, made of the input state (control to return addr)
1602  * and the given constant result. Idealization of projections will make sure to transparently
1603  * propagate the input state and replace the result by the said constant.
1604  */
1605 TupleNode* ModFloatingNode::make_tuple_of_input_state_and_constant_result(PhaseIterGVN* phase, const Type* con) const {
1606   Node* con_node = phase->makecon(con);
1607   TupleNode* tuple = TupleNode::make(
1608       tf()->range_cc(),
1609       in(TypeFunc::Control),
1610       in(TypeFunc::I_O),
1611       in(TypeFunc::Memory),
1612       in(TypeFunc::FramePtr),
1613       in(TypeFunc::ReturnAdr),
1614       con_node);
1615 
1616   return tuple;
1617 }
1618 
1619 //=============================================================================
1620 
1621 DivModNode::DivModNode( Node *c, Node *dividend, Node *divisor ) : MultiNode(3) {
1622   init_req(0, c);
1623   init_req(1, dividend);
1624   init_req(2, divisor);
1625 }
1626 
1627 DivModNode* DivModNode::make(Node* div_or_mod, BasicType bt, bool is_unsigned) {
1628   assert(bt == T_INT || bt == T_LONG, "only int or long input pattern accepted");

1651   DivModINode* divmod = new DivModINode(n->in(0), n->in(1), n->in(2));
1652   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1653   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1654   return divmod;
1655 }
1656 
1657 //------------------------------make------------------------------------------
1658 DivModLNode* DivModLNode::make(Node* div_or_mod) {
1659   Node* n = div_or_mod;
1660   assert(n->Opcode() == Op_DivL || n->Opcode() == Op_ModL,
1661          "only div or mod input pattern accepted");
1662 
1663   DivModLNode* divmod = new DivModLNode(n->in(0), n->in(1), n->in(2));
1664   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1665   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1666   return divmod;
1667 }
1668 
1669 //------------------------------match------------------------------------------
1670 // return result(s) along with their RegMask info
1671 Node *DivModINode::match(const ProjNode *proj, const Matcher *match, const RegMask* mask) {
1672   uint ideal_reg = proj->ideal_reg();
1673   RegMask rm;
1674   if (proj->_con == div_proj_num) {
1675     rm = match->divI_proj_mask();
1676   } else {
1677     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1678     rm = match->modI_proj_mask();
1679   }
1680   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1681 }
1682 
1683 
1684 //------------------------------match------------------------------------------
1685 // return result(s) along with their RegMask info
1686 Node *DivModLNode::match(const ProjNode *proj, const Matcher *match, const RegMask* mask) {
1687   uint ideal_reg = proj->ideal_reg();
1688   RegMask rm;
1689   if (proj->_con == div_proj_num) {
1690     rm = match->divL_proj_mask();
1691   } else {
1692     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1693     rm = match->modL_proj_mask();
1694   }
1695   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1696 }
1697 
1698 //------------------------------make------------------------------------------
1699 UDivModINode* UDivModINode::make(Node* div_or_mod) {
1700   Node* n = div_or_mod;
1701   assert(n->Opcode() == Op_UDivI || n->Opcode() == Op_UModI,
1702          "only div or mod input pattern accepted");
1703 
1704   UDivModINode* divmod = new UDivModINode(n->in(0), n->in(1), n->in(2));
1705   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1706   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1707   return divmod;
1708 }
1709 
1710 //------------------------------make------------------------------------------
1711 UDivModLNode* UDivModLNode::make(Node* div_or_mod) {
1712   Node* n = div_or_mod;
1713   assert(n->Opcode() == Op_UDivL || n->Opcode() == Op_UModL,
1714          "only div or mod input pattern accepted");
1715 
1716   UDivModLNode* divmod = new UDivModLNode(n->in(0), n->in(1), n->in(2));
1717   Node*        dproj  = new ProjNode(divmod, DivModNode::div_proj_num);
1718   Node*        mproj  = new ProjNode(divmod, DivModNode::mod_proj_num);
1719   return divmod;
1720 }
1721 
1722 //------------------------------match------------------------------------------
1723 // return result(s) along with their RegMask info
1724 Node* UDivModINode::match(const ProjNode* proj, const Matcher* match, const RegMask* mask) {
1725   uint ideal_reg = proj->ideal_reg();
1726   RegMask rm;
1727   if (proj->_con == div_proj_num) {
1728     rm = match->divI_proj_mask();
1729   } else {
1730     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1731     rm = match->modI_proj_mask();
1732   }
1733   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1734 }
1735 
1736 
1737 //------------------------------match------------------------------------------
1738 // return result(s) along with their RegMask info
1739 Node* UDivModLNode::match( const ProjNode* proj, const Matcher* match, const RegMask* mask) {
1740   uint ideal_reg = proj->ideal_reg();
1741   RegMask rm;
1742   if (proj->_con == div_proj_num) {
1743     rm = match->divL_proj_mask();
1744   } else {
1745     assert(proj->_con == mod_proj_num, "must be div or mod projection");
1746     rm = match->modL_proj_mask();
1747   }
1748   return new MachProjNode(this, proj->_con, rm, ideal_reg);
1749 }
< prev index next >