src/share/vm/opto/mathexactnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8054033 Sdiff src/share/vm/opto

src/share/vm/opto/mathexactnode.cpp

Print this page


   1 /*
   2  * Copyright (c) 2013, 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  *


 174 template <typename OverflowOp>
 175 struct IdealHelper {
 176   typedef typename OverflowOp::TypeClass TypeClass; // TypeInt, TypeLong
 177   typedef typename TypeClass::NativeType NativeType;
 178 
 179   static Node* Ideal(const OverflowOp* node, PhaseGVN* phase, bool can_reshape) {
 180     Node* arg1 = node->in(1);
 181     Node* arg2 = node->in(2);
 182     const Type* type1 = phase->type(arg1);
 183     const Type* type2 = phase->type(arg2);
 184 
 185     if (type1 == NULL || type2 == NULL) {
 186       return NULL;
 187     }
 188 
 189     if (type1 != Type::TOP && type1->singleton() &&
 190         type2 != Type::TOP && type2->singleton()) {
 191       NativeType val1 = TypeClass::as_self(type1)->get_con();
 192       NativeType val2 = TypeClass::as_self(type2)->get_con();
 193       if (node->will_overflow(val1, val2) == false) {
 194         Node* con_result = ConINode::make(phase->C, 0);
 195         return con_result;
 196       }
 197       return NULL;
 198     }
 199     return NULL;
 200   }
 201 
 202   static const Type* Value(const OverflowOp* node, PhaseTransform* phase) {
 203     const Type *t1 = phase->type( node->in(1) );
 204     const Type *t2 = phase->type( node->in(2) );
 205     if( t1 == Type::TOP ) return Type::TOP;
 206     if( t2 == Type::TOP ) return Type::TOP;
 207 
 208     const TypeClass* i1 = TypeClass::as_self(t1);
 209     const TypeClass* i2 = TypeClass::as_self(t2);
 210 
 211     if (i1 == NULL || i2 == NULL) {
 212       return TypeInt::CC;
 213     }
 214 


   1 /*
   2  * Copyright (c) 2013, 2014, 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  *


 174 template <typename OverflowOp>
 175 struct IdealHelper {
 176   typedef typename OverflowOp::TypeClass TypeClass; // TypeInt, TypeLong
 177   typedef typename TypeClass::NativeType NativeType;
 178 
 179   static Node* Ideal(const OverflowOp* node, PhaseGVN* phase, bool can_reshape) {
 180     Node* arg1 = node->in(1);
 181     Node* arg2 = node->in(2);
 182     const Type* type1 = phase->type(arg1);
 183     const Type* type2 = phase->type(arg2);
 184 
 185     if (type1 == NULL || type2 == NULL) {
 186       return NULL;
 187     }
 188 
 189     if (type1 != Type::TOP && type1->singleton() &&
 190         type2 != Type::TOP && type2->singleton()) {
 191       NativeType val1 = TypeClass::as_self(type1)->get_con();
 192       NativeType val2 = TypeClass::as_self(type2)->get_con();
 193       if (node->will_overflow(val1, val2) == false) {
 194         Node* con_result = ConINode::make(0);
 195         return con_result;
 196       }
 197       return NULL;
 198     }
 199     return NULL;
 200   }
 201 
 202   static const Type* Value(const OverflowOp* node, PhaseTransform* phase) {
 203     const Type *t1 = phase->type( node->in(1) );
 204     const Type *t2 = phase->type( node->in(2) );
 205     if( t1 == Type::TOP ) return Type::TOP;
 206     if( t2 == Type::TOP ) return Type::TOP;
 207 
 208     const TypeClass* i1 = TypeClass::as_self(t1);
 209     const TypeClass* i2 = TypeClass::as_self(t2);
 210 
 211     if (i1 == NULL || i2 == NULL) {
 212       return TypeInt::CC;
 213     }
 214 


src/share/vm/opto/mathexactnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File