< prev index next >

src/hotspot/share/opto/convertnode.cpp

Print this page

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "opto/addnode.hpp"
 27 #include "opto/castnode.hpp"
 28 #include "opto/connode.hpp"
 29 #include "opto/convertnode.hpp"

 30 #include "opto/matcher.hpp"
 31 #include "opto/movenode.hpp"
 32 #include "opto/phaseX.hpp"
 33 #include "opto/subnode.hpp"
 34 #include "runtime/stubRoutines.hpp"
 35 #include "utilities/checkedCast.hpp"
 36 
 37 //=============================================================================
 38 //------------------------------Identity---------------------------------------
 39 Node* Conv2BNode::Identity(PhaseGVN* phase) {
 40   const Type *t = phase->type( in(1) );
 41   if( t == Type::TOP ) return in(1);
 42   if( t == TypeInt::ZERO ) return in(1);
 43   if( t == TypeInt::ONE ) return in(1);
 44   if( t == TypeInt::BOOL ) return in(1);
 45   return this;
 46 }
 47 
 48 //------------------------------Value------------------------------------------
 49 const Type* Conv2BNode::Value(PhaseGVN* phase) const {
 50   const Type *t = phase->type( in(1) );
 51   if( t == Type::TOP ) return Type::TOP;
 52   if( t == TypeInt::ZERO ) return TypeInt::ZERO;
 53   if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
 54   const TypePtr *tp = t->isa_ptr();
 55   if(tp != nullptr) {
 56     if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP;
 57     if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE;
 58     if (tp->ptr() == TypePtr::NotNull)  return TypeInt::ONE;
 59     return TypeInt::BOOL;
 60   }
 61   if (t->base() != Type::Int) return TypeInt::BOOL;
 62   const TypeInt *ti = t->is_int();
 63   if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE;
 64   return TypeInt::BOOL;
 65 }
 66 

 67 Node* Conv2BNode::Ideal(PhaseGVN* phase, bool can_reshape) {






 68   if (!Matcher::match_rule_supported(Op_Conv2B)) {
 69     if (phase->C->post_loop_opts_phase()) {
 70       // Get type of comparison to make
 71       const Type* t = phase->type(in(1));
 72       Node* cmp = nullptr;
 73       if (t->isa_int()) {
 74         cmp = phase->transform(new CmpINode(in(1), phase->intcon(0)));
 75       } else if (t->isa_ptr()) {
 76         cmp = phase->transform(new CmpPNode(in(1), phase->zerocon(BasicType::T_OBJECT)));
 77       } else {
 78         assert(false, "Unrecognized comparison for Conv2B: %s", NodeClassNames[in(1)->Opcode()]);
 79       }
 80 
 81       // Replace Conv2B with the cmove
 82       Node* bol = phase->transform(new BoolNode(cmp, BoolTest::eq));
 83       return new CMoveINode(bol, phase->intcon(1), phase->intcon(0), TypeInt::BOOL);
 84     } else {
 85       phase->C->record_for_post_loop_opts_igvn(this);
 86     }
 87   }

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "opto/addnode.hpp"
 27 #include "opto/castnode.hpp"
 28 #include "opto/connode.hpp"
 29 #include "opto/convertnode.hpp"
 30 #include "opto/inlinetypenode.hpp"
 31 #include "opto/matcher.hpp"
 32 #include "opto/movenode.hpp"
 33 #include "opto/phaseX.hpp"
 34 #include "opto/subnode.hpp"
 35 #include "runtime/stubRoutines.hpp"
 36 #include "utilities/checkedCast.hpp"
 37 
 38 //=============================================================================
 39 //------------------------------Identity---------------------------------------
 40 Node* Conv2BNode::Identity(PhaseGVN* phase) {
 41   const Type *t = phase->type( in(1) );
 42   if( t == Type::TOP ) return in(1);
 43   if( t == TypeInt::ZERO ) return in(1);
 44   if( t == TypeInt::ONE ) return in(1);
 45   if( t == TypeInt::BOOL ) return in(1);
 46   return this;
 47 }
 48 
 49 //------------------------------Value------------------------------------------
 50 const Type* Conv2BNode::Value(PhaseGVN* phase) const {
 51   const Type *t = phase->type( in(1) );
 52   if( t == Type::TOP ) return Type::TOP;
 53   if( t == TypeInt::ZERO ) return TypeInt::ZERO;
 54   if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
 55   const TypePtr *tp = t->isa_ptr();
 56   if(tp != nullptr) {
 57     if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP;
 58     if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE;
 59     if (tp->ptr() == TypePtr::NotNull)  return TypeInt::ONE;
 60     return TypeInt::BOOL;
 61   }
 62   if (t->base() != Type::Int) return TypeInt::BOOL;
 63   const TypeInt *ti = t->is_int();
 64   if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE;
 65   return TypeInt::BOOL;
 66 }
 67 
 68 //------------------------------Ideal------------------------------------------
 69 Node* Conv2BNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 70   if (in(1)->is_InlineType()) {
 71     // Null checking a scalarized but nullable inline type. Check the IsInit
 72     // input instead of the oop input to avoid keeping buffer allocations alive.
 73     set_req_X(1, in(1)->as_InlineType()->get_is_init(), phase);
 74     return this;
 75   }
 76   if (!Matcher::match_rule_supported(Op_Conv2B)) {
 77     if (phase->C->post_loop_opts_phase()) {
 78       // Get type of comparison to make
 79       const Type* t = phase->type(in(1));
 80       Node* cmp = nullptr;
 81       if (t->isa_int()) {
 82         cmp = phase->transform(new CmpINode(in(1), phase->intcon(0)));
 83       } else if (t->isa_ptr()) {
 84         cmp = phase->transform(new CmpPNode(in(1), phase->zerocon(BasicType::T_OBJECT)));
 85       } else {
 86         assert(false, "Unrecognized comparison for Conv2B: %s", NodeClassNames[in(1)->Opcode()]);
 87       }
 88 
 89       // Replace Conv2B with the cmove
 90       Node* bol = phase->transform(new BoolNode(cmp, BoolTest::eq));
 91       return new CMoveINode(bol, phase->intcon(1), phase->intcon(0), TypeInt::BOOL);
 92     } else {
 93       phase->C->record_for_post_loop_opts_igvn(this);
 94     }
 95   }
< prev index next >