< prev index next >

src/hotspot/share/opto/convertnode.cpp

Print this page

  1 /*
  2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 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/convertnode.hpp"

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










 64 
 65 // The conversions operations are all Alpha sorted.  Please keep it that way!
 66 //=============================================================================
 67 //------------------------------Value------------------------------------------
 68 const Type* ConvD2FNode::Value(PhaseGVN* phase) const {
 69   const Type *t = phase->type( in(1) );
 70   if( t == Type::TOP ) return Type::TOP;
 71   if( t == Type::DOUBLE ) return Type::FLOAT;
 72   const TypeD *td = t->is_double_constant();
 73   return TypeF::make( (float)td->getd() );
 74 }
 75 
 76 //------------------------------Ideal------------------------------------------
 77 // If we see pattern ConvF2D SomeDoubleOp ConvD2F, do operation as float.
 78 Node *ConvD2FNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 79   if ( in(1)->Opcode() == Op_SqrtD ) {
 80     Node* sqrtd = in(1);
 81     if ( sqrtd->in(1)->Opcode() == Op_ConvF2D ) {
 82       if ( Matcher::match_rule_supported(Op_SqrtF) ) {
 83         Node* convf2d = sqrtd->in(1);

  1 /*
  2  * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 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/convertnode.hpp"
 29 #include "opto/inlinetypenode.hpp"
 30 #include "opto/matcher.hpp"
 31 #include "opto/phaseX.hpp"
 32 #include "opto/subnode.hpp"
 33 #include "runtime/sharedRuntime.hpp"
 34 
 35 //=============================================================================
 36 //------------------------------Identity---------------------------------------
 37 Node* Conv2BNode::Identity(PhaseGVN* phase) {
 38   const Type *t = phase->type( in(1) );
 39   if( t == Type::TOP ) return in(1);
 40   if( t == TypeInt::ZERO ) return in(1);
 41   if( t == TypeInt::ONE ) return in(1);
 42   if( t == TypeInt::BOOL ) return in(1);
 43   return this;
 44 }
 45 
 46 //------------------------------Value------------------------------------------
 47 const Type* Conv2BNode::Value(PhaseGVN* phase) const {
 48   const Type *t = phase->type( in(1) );
 49   if( t == Type::TOP ) return Type::TOP;
 50   if( t == TypeInt::ZERO ) return TypeInt::ZERO;
 51   if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
 52   const TypePtr *tp = t->isa_ptr();
 53   if( tp != NULL ) {
 54     if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP;
 55     if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE;
 56     if (tp->ptr() == TypePtr::NotNull)  return TypeInt::ONE;
 57     return TypeInt::BOOL;
 58   }
 59   if (t->base() != Type::Int) return TypeInt::BOOL;
 60   const TypeInt *ti = t->is_int();
 61   if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE;
 62   return TypeInt::BOOL;
 63 }
 64 
 65 //------------------------------Ideal------------------------------------------
 66 Node* Conv2BNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 67   if (in(1)->is_InlineTypePtr()) {
 68     // Null checking a scalarized but nullable inline type. Check the is_init
 69     // input instead of the oop input to avoid keeping buffer allocations alive.
 70     set_req_X(1, in(1)->as_InlineTypePtr()->get_is_init(), phase);
 71     return this;
 72   }
 73   return NULL;
 74 }
 75 
 76 // The conversions operations are all Alpha sorted.  Please keep it that way!
 77 //=============================================================================
 78 //------------------------------Value------------------------------------------
 79 const Type* ConvD2FNode::Value(PhaseGVN* phase) const {
 80   const Type *t = phase->type( in(1) );
 81   if( t == Type::TOP ) return Type::TOP;
 82   if( t == Type::DOUBLE ) return Type::FLOAT;
 83   const TypeD *td = t->is_double_constant();
 84   return TypeF::make( (float)td->getd() );
 85 }
 86 
 87 //------------------------------Ideal------------------------------------------
 88 // If we see pattern ConvF2D SomeDoubleOp ConvD2F, do operation as float.
 89 Node *ConvD2FNode::Ideal(PhaseGVN *phase, bool can_reshape) {
 90   if ( in(1)->Opcode() == Op_SqrtD ) {
 91     Node* sqrtd = in(1);
 92     if ( sqrtd->in(1)->Opcode() == Op_ConvF2D ) {
 93       if ( Matcher::match_rule_supported(Op_SqrtF) ) {
 94         Node* convf2d = sqrtd->in(1);
< prev index next >