< 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 "opto/addnode.hpp"
 26 #include "opto/castnode.hpp"
 27 #include "opto/connode.hpp"
 28 #include "opto/convertnode.hpp"
 29 #include "opto/divnode.hpp"

 30 #include "opto/matcher.hpp"
 31 #include "opto/movenode.hpp"
 32 #include "opto/mulnode.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 Node* Conv2BNode::Ideal(PhaseGVN* phase, bool can_reshape) {






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

 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 "opto/addnode.hpp"
 26 #include "opto/castnode.hpp"
 27 #include "opto/connode.hpp"
 28 #include "opto/convertnode.hpp"
 29 #include "opto/divnode.hpp"
 30 #include "opto/inlinetypenode.hpp"
 31 #include "opto/matcher.hpp"
 32 #include "opto/movenode.hpp"
 33 #include "opto/mulnode.hpp"
 34 #include "opto/phaseX.hpp"
 35 #include "opto/subnode.hpp"
 36 #include "runtime/stubRoutines.hpp"
 37 #include "utilities/checkedCast.hpp"
 38 
 39 //=============================================================================
 40 //------------------------------Identity---------------------------------------
 41 Node* Conv2BNode::Identity(PhaseGVN* phase) {
 42   const Type *t = phase->type( in(1) );
 43   if( t == Type::TOP ) return in(1);
 44   if( t == TypeInt::ZERO ) return in(1);
 45   if( t == TypeInt::ONE ) return in(1);
 46   if( t == TypeInt::BOOL ) return in(1);
 47   return this;
 48 }
 49 
 50 //------------------------------Value------------------------------------------
 51 const Type* Conv2BNode::Value(PhaseGVN* phase) const {
 52   const Type *t = phase->type( in(1) );
 53   if( t == Type::TOP ) return Type::TOP;
 54   if( t == TypeInt::ZERO ) return TypeInt::ZERO;
 55   if( t == TypePtr::NULL_PTR ) return TypeInt::ZERO;
 56   const TypePtr *tp = t->isa_ptr();
 57   if(tp != nullptr) {
 58     if( tp->ptr() == TypePtr::AnyNull ) return Type::TOP;
 59     if( tp->ptr() == TypePtr::Constant) return TypeInt::ONE;
 60     if (tp->ptr() == TypePtr::NotNull)  return TypeInt::ONE;
 61     return TypeInt::BOOL;
 62   }
 63   if (t->base() != Type::Int) return TypeInt::BOOL;
 64   const TypeInt *ti = t->is_int();
 65   if( ti->_hi < 0 || ti->_lo > 0 ) return TypeInt::ONE;
 66   return TypeInt::BOOL;
 67 }
 68 
 69 //------------------------------Ideal------------------------------------------
 70 Node* Conv2BNode::Ideal(PhaseGVN* phase, bool can_reshape) {
 71   if (in(1)->is_InlineType()) {
 72     // Null checking a scalarized but nullable inline type. Check the IsInit
 73     // input instead of the oop input to avoid keeping buffer allocations alive.
 74     set_req_X(1, in(1)->as_InlineType()->get_is_init(), phase);
 75     return this;
 76   }
 77   if (!Matcher::match_rule_supported(Op_Conv2B)) {
 78     if (phase->C->post_loop_opts_phase()) {
 79       // Get type of comparison to make
 80       const Type* t = phase->type(in(1));
 81       Node* cmp = nullptr;
 82       if (t->isa_int()) {
 83         cmp = phase->transform(new CmpINode(in(1), phase->intcon(0)));
 84       } else if (t->isa_ptr()) {
 85         cmp = phase->transform(new CmpPNode(in(1), phase->zerocon(BasicType::T_OBJECT)));
 86       } else {
 87         assert(false, "Unrecognized comparison for Conv2B: %s", NodeClassNames[in(1)->Opcode()]);
 88       }
 89 
 90       // Replace Conv2B with the cmove
 91       Node* bol = phase->transform(new BoolNode(cmp, BoolTest::eq));
 92       return new CMoveINode(bol, phase->intcon(1), phase->intcon(0), TypeInt::BOOL);
 93     } else {
 94       phase->C->record_for_post_loop_opts_igvn(this);
 95     }
 96   }
< prev index next >