src/hotspot/share/opto/mathexactnode.hpp
author rbackman
Thu, 18 Jan 2018 19:21:11 +0100
changeset 48809 a81c930a8838
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
permissions -rw-r--r--
8191915: JCK tests produce incorrect results with C2 Reviewed-by: thartmann, vlivanov, goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     1
/*
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     4
 *
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     8
 *
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    13
 * accompanied this code).
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    14
 *
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    18
 *
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    21
 * questions.
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    22
 *
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    23
 */
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    24
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    25
#ifndef SHARE_VM_OPTO_MATHEXACTNODE_HPP
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    26
#define SHARE_VM_OPTO_MATHEXACTNODE_HPP
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    27
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    28
#include "opto/multnode.hpp"
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    29
#include "opto/node.hpp"
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    30
#include "opto/addnode.hpp"
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents: 20289
diff changeset
    31
#include "opto/subnode.hpp"
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    32
#include "opto/type.hpp"
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    33
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    34
class PhaseGVN;
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    35
class PhaseTransform;
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    36
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    37
class OverflowNode : public CmpNode {
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    38
public:
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    39
  OverflowNode(Node* in1, Node* in2) : CmpNode(in1, in2) {}
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    40
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    41
  virtual uint ideal_reg() const { return Op_RegFlags; }
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    42
  virtual const Type* sub(const Type* t1, const Type* t2) const;
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    43
};
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    44
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    45
class OverflowINode : public OverflowNode {
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    46
public:
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    47
  typedef TypeInt TypeClass;
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    48
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    49
  OverflowINode(Node* in1, Node* in2) : OverflowNode(in1, in2) {}
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    50
  virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 22911
diff changeset
    51
  virtual const Type* Value(PhaseGVN* phase) const;
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    52
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    53
  virtual bool will_overflow(jint v1, jint v2) const = 0;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    54
  virtual bool can_overflow(const Type* t1, const Type* t2) const = 0;
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    55
};
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    56
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
    57
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    58
class OverflowLNode : public OverflowNode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    59
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    60
  typedef TypeLong TypeClass;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    61
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    62
  OverflowLNode(Node* in1, Node* in2) : OverflowNode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    63
  virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 22911
diff changeset
    64
  virtual const Type* Value(PhaseGVN* phase) const;
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    65
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    66
  virtual bool will_overflow(jlong v1, jlong v2) const = 0;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    67
  virtual bool can_overflow(const Type* t1, const Type* t2) const = 0;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    68
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    69
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    70
class OverflowAddINode : public OverflowINode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    71
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    72
  typedef AddINode MathOp;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    73
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    74
  OverflowAddINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    75
  virtual int Opcode() const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    76
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    77
  virtual bool will_overflow(jint v1, jint v2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    78
  virtual bool can_overflow(const Type* t1, const Type* t2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    79
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    80
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    81
class OverflowSubINode : public OverflowINode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    82
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    83
  typedef SubINode MathOp;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    84
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    85
  OverflowSubINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    86
  virtual int Opcode() const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    87
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    88
  virtual bool will_overflow(jint v1, jint v2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    89
  virtual bool can_overflow(const Type* t1, const Type* t2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    90
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    91
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    92
class OverflowMulINode : public OverflowINode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    93
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    94
  typedef MulINode MathOp;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    95
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    96
  OverflowMulINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    97
  virtual int Opcode() const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    98
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
    99
  virtual bool will_overflow(jint v1, jint v2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   100
  virtual bool can_overflow(const Type* t1, const Type* t2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   101
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   102
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   103
class OverflowAddLNode : public OverflowLNode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   104
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   105
  typedef AddLNode MathOp;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   106
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   107
  OverflowAddLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   108
  virtual int Opcode() const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   109
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   110
  virtual bool will_overflow(jlong v1, jlong v2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   111
  virtual bool can_overflow(const Type* t1, const Type* t2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   112
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   113
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   114
class OverflowSubLNode : public OverflowLNode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   115
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   116
  typedef SubLNode MathOp;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   117
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   118
  OverflowSubLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   119
  virtual int Opcode() const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   120
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   121
  virtual bool will_overflow(jlong v1, jlong v2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   122
  virtual bool can_overflow(const Type* t1, const Type* t2) const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   123
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   124
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   125
class OverflowMulLNode : public OverflowLNode {
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   126
public:
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   127
  typedef MulLNode MathOp;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   128
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   129
  OverflowMulLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   130
  virtual int Opcode() const;
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   131
48809
a81c930a8838 8191915: JCK tests produce incorrect results with C2
rbackman
parents: 47216
diff changeset
   132
  virtual bool will_overflow(jlong v1, jlong v2) const { return is_overflow(v1, v2); }
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   133
  virtual bool can_overflow(const Type* t1, const Type* t2) const;
48809
a81c930a8838 8191915: JCK tests produce incorrect results with C2
rbackman
parents: 47216
diff changeset
   134
a81c930a8838 8191915: JCK tests produce incorrect results with C2
rbackman
parents: 47216
diff changeset
   135
  static bool is_overflow(jlong v1, jlong v2);
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   136
};
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21578
diff changeset
   137
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
   138
#endif
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents:
diff changeset
   139