Mercurial > hg > truffle
annotate src/share/vm/opto/mathexactnode.cpp @ 13241:8b5852df0471
remove CompilerToVM.initializeMethodData
author | twisti |
---|---|
date | Tue, 03 Dec 2013 14:48:09 -0800 |
parents | 59e8ad757e19 |
children | cd5d10655495 |
rev | line source |
---|---|
12323 | 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 * | |
23 */ | |
24 | |
25 #include "precompiled.hpp" | |
26 #include "memory/allocation.inline.hpp" | |
27 #include "opto/addnode.hpp" | |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
28 #include "opto/cfgnode.hpp" |
12323 | 29 #include "opto/machnode.hpp" |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
30 #include "opto/matcher.hpp" |
12323 | 31 #include "opto/mathexactnode.hpp" |
32 #include "opto/subnode.hpp" | |
33 | |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
34 MathExactNode::MathExactNode(Node* ctrl, Node* in1) : MultiNode(2) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
35 init_class_id(Class_MathExact); |
12323 | 36 init_req(0, ctrl); |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
37 init_req(1, in1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
38 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
39 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
40 MathExactNode::MathExactNode(Node* ctrl, Node* in1, Node* in2) : MultiNode(3) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
41 init_class_id(Class_MathExact); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
42 init_req(0, ctrl); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
43 init_req(1, in1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
44 init_req(2, in2); |
12323 | 45 } |
46 | |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
47 BoolNode* MathExactNode::bool_node() const { |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
48 Node* flags = flags_node(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
49 BoolNode* boolnode = flags->unique_out()->as_Bool(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
50 assert(boolnode != NULL, "must have BoolNode"); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
51 return boolnode; |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
52 } |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
53 |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
54 IfNode* MathExactNode::if_node() const { |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
55 BoolNode* boolnode = bool_node(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
56 IfNode* ifnode = boolnode->unique_out()->as_If(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
57 assert(ifnode != NULL, "must have IfNode"); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
58 return ifnode; |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
59 } |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
60 |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
61 Node* MathExactNode::control_node() const { |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
62 IfNode* ifnode = if_node(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
63 return ifnode->in(0); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
64 } |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
65 |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
66 Node* MathExactNode::non_throwing_branch() const { |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
67 IfNode* ifnode = if_node(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
68 if (bool_node()->_test._test == BoolTest::overflow) { |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
69 return ifnode->proj_out(0); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
70 } |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
71 return ifnode->proj_out(1); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
72 } |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
73 |
12323 | 74 // If the MathExactNode won't overflow we have to replace the |
75 // FlagsProjNode and ProjNode that is generated by the MathExactNode | |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
76 Node* MathExactNode::no_overflow(PhaseGVN* phase, Node* new_result) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
77 PhaseIterGVN* igvn = phase->is_IterGVN(); |
12323 | 78 if (igvn) { |
79 ProjNode* result = result_node(); | |
80 ProjNode* flags = flags_node(); | |
81 | |
82 if (result != NULL) { | |
83 igvn->replace_node(result, new_result); | |
84 } | |
85 | |
86 if (flags != NULL) { | |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
87 BoolNode* boolnode = bool_node(); |
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
88 switch (boolnode->_test._test) { |
12323 | 89 case BoolTest::overflow: |
90 // if the check is for overflow - never taken | |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
91 igvn->replace_node(boolnode, phase->intcon(0)); |
12323 | 92 break; |
93 case BoolTest::no_overflow: | |
94 // if the check is for no overflow - always taken | |
12888
4a2acfb16e97
8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
12323
diff
changeset
|
95 igvn->replace_node(boolnode, phase->intcon(1)); |
12323 | 96 break; |
97 default: | |
98 fatal("Unexpected value of BoolTest"); | |
99 break; | |
100 } | |
101 flags->del_req(0); | |
102 } | |
103 } | |
104 return new_result; | |
105 } | |
106 | |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
107 Node* MathExactINode::match(const ProjNode* proj, const Matcher* m) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
108 uint ideal_reg = proj->ideal_reg(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
109 RegMask rm; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
110 if (proj->_con == result_proj_node) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
111 rm = m->mathExactI_result_proj_mask(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
112 } else { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
113 assert(proj->_con == flags_proj_node, "must be result or flags"); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
114 assert(ideal_reg == Op_RegFlags, "sanity"); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
115 rm = m->mathExactI_flags_proj_mask(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
116 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
117 return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
118 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
119 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
120 Node* MathExactLNode::match(const ProjNode* proj, const Matcher* m) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
121 uint ideal_reg = proj->ideal_reg(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
122 RegMask rm; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
123 if (proj->_con == result_proj_node) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
124 rm = m->mathExactL_result_proj_mask(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
125 } else { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
126 assert(proj->_con == flags_proj_node, "must be result or flags"); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
127 assert(ideal_reg == Op_RegFlags, "sanity"); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
128 rm = m->mathExactI_flags_proj_mask(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
129 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
130 return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
131 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
132 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
133 Node* AddExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
134 Node* arg1 = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
135 Node* arg2 = in(2); |
12323 | 136 |
137 const Type* type1 = phase->type(arg1); | |
138 const Type* type2 = phase->type(arg2); | |
139 | |
140 if (type1 != Type::TOP && type1->singleton() && | |
141 type2 != Type::TOP && type2->singleton()) { | |
142 jint val1 = arg1->get_int(); | |
143 jint val2 = arg2->get_int(); | |
144 jint result = val1 + val2; | |
145 // Hacker's Delight 2-12 Overflow if both arguments have the opposite sign of the result | |
146 if ( (((val1 ^ result) & (val2 ^ result)) >= 0)) { | |
147 Node* con_result = ConINode::make(phase->C, result); | |
148 return no_overflow(phase, con_result); | |
149 } | |
150 return NULL; | |
151 } | |
152 | |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
153 if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { // (Add 0 x) == x |
12323 | 154 Node* add_result = new (phase->C) AddINode(arg1, arg2); |
155 return no_overflow(phase, add_result); | |
156 } | |
157 | |
158 if (type2->singleton()) { | |
159 return NULL; // no change - keep constant on the right | |
160 } | |
161 | |
162 if (type1->singleton()) { | |
163 // Make it x + Constant - move constant to the right | |
164 swap_edges(1, 2); | |
165 return this; | |
166 } | |
167 | |
168 if (arg2->is_Load()) { | |
169 return NULL; // no change - keep load on the right | |
170 } | |
171 | |
172 if (arg1->is_Load()) { | |
173 // Make it x + Load - move load to the right | |
174 swap_edges(1, 2); | |
175 return this; | |
176 } | |
177 | |
178 if (arg1->_idx > arg2->_idx) { | |
179 // Sort the edges | |
180 swap_edges(1, 2); | |
181 return this; | |
182 } | |
183 | |
184 return NULL; | |
185 } | |
186 | |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
187 Node* AddExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
188 Node* arg1 = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
189 Node* arg2 = in(2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
190 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
191 const Type* type1 = phase->type(arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
192 const Type* type2 = phase->type(arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
193 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
194 if (type1 != Type::TOP && type1->singleton() && |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
195 type2 != Type::TOP && type2->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
196 jlong val1 = arg1->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
197 jlong val2 = arg2->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
198 jlong result = val1 + val2; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
199 // Hacker's Delight 2-12 Overflow if both arguments have the opposite sign of the result |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
200 if ( (((val1 ^ result) & (val2 ^ result)) >= 0)) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
201 Node* con_result = ConLNode::make(phase->C, result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
202 return no_overflow(phase, con_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
203 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
204 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
205 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
206 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
207 if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { // (Add 0 x) == x |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
208 Node* add_result = new (phase->C) AddLNode(arg1, arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
209 return no_overflow(phase, add_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
210 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
211 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
212 if (type2->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
213 return NULL; // no change - keep constant on the right |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
214 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
215 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
216 if (type1->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
217 // Make it x + Constant - move constant to the right |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
218 swap_edges(1, 2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
219 return this; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
220 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
221 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
222 if (arg2->is_Load()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
223 return NULL; // no change - keep load on the right |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
224 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
225 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
226 if (arg1->is_Load()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
227 // Make it x + Load - move load to the right |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
228 swap_edges(1, 2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
229 return this; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
230 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
231 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
232 if (arg1->_idx > arg2->_idx) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
233 // Sort the edges |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
234 swap_edges(1, 2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
235 return this; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
236 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
237 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
238 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
239 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
240 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
241 Node* SubExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
242 Node* arg1 = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
243 Node* arg2 = in(2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
244 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
245 const Type* type1 = phase->type(arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
246 const Type* type2 = phase->type(arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
247 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
248 if (type1 != Type::TOP && type1->singleton() && |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
249 type2 != Type::TOP && type2->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
250 jint val1 = arg1->get_int(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
251 jint val2 = arg2->get_int(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
252 jint result = val1 - val2; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
253 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
254 // Hacker's Delight 2-12 Overflow iff the arguments have different signs and |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
255 // the sign of the result is different than the sign of arg1 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
256 if (((val1 ^ val2) & (val1 ^ result)) >= 0) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
257 Node* con_result = ConINode::make(phase->C, result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
258 return no_overflow(phase, con_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
259 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
260 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
261 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
262 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
263 if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
264 // Sub with zero is the same as add with zero |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
265 Node* add_result = new (phase->C) AddINode(arg1, arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
266 return no_overflow(phase, add_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
267 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
268 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
269 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
270 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
271 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
272 Node* SubExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
273 Node* arg1 = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
274 Node* arg2 = in(2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
275 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
276 const Type* type1 = phase->type(arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
277 const Type* type2 = phase->type(arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
278 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
279 if (type1 != Type::TOP && type1->singleton() && |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
280 type2 != Type::TOP && type2->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
281 jlong val1 = arg1->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
282 jlong val2 = arg2->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
283 jlong result = val1 - val2; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
284 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
285 // Hacker's Delight 2-12 Overflow iff the arguments have different signs and |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
286 // the sign of the result is different than the sign of arg1 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
287 if (((val1 ^ val2) & (val1 ^ result)) >= 0) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
288 Node* con_result = ConLNode::make(phase->C, result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
289 return no_overflow(phase, con_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
290 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
291 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
292 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
293 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
294 if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
295 // Sub with zero is the same as add with zero |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
296 Node* add_result = new (phase->C) AddLNode(arg1, arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
297 return no_overflow(phase, add_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
298 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
299 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
300 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
301 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
302 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
303 Node* NegExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
304 Node *arg = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
305 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
306 const Type* type = phase->type(arg); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
307 if (type != Type::TOP && type->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
308 jint value = arg->get_int(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
309 if (value != min_jint) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
310 Node* neg_result = ConINode::make(phase->C, -value); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
311 return no_overflow(phase, neg_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
312 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
313 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
314 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
315 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
316 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
317 Node* NegExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
318 Node *arg = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
319 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
320 const Type* type = phase->type(arg); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
321 if (type != Type::TOP && type->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
322 jlong value = arg->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
323 if (value != min_jlong) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
324 Node* neg_result = ConLNode::make(phase->C, -value); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
325 return no_overflow(phase, neg_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
326 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
327 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
328 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
329 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
330 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
331 Node* MulExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
332 Node* arg1 = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
333 Node* arg2 = in(2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
334 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
335 const Type* type1 = phase->type(arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
336 const Type* type2 = phase->type(arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
337 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
338 if (type1 != Type::TOP && type1->singleton() && |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
339 type2 != Type::TOP && type2->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
340 jint val1 = arg1->get_int(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
341 jint val2 = arg2->get_int(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
342 jlong result = (jlong) val1 * (jlong) val2; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
343 if ((jint) result == result) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
344 // no overflow |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
345 Node* mul_result = ConINode::make(phase->C, result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
346 return no_overflow(phase, mul_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
347 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
348 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
349 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
350 if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
351 return no_overflow(phase, ConINode::make(phase->C, 0)); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
352 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
353 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
354 if (type1 == TypeInt::ONE) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
355 Node* mul_result = new (phase->C) AddINode(arg2, phase->intcon(0)); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
356 return no_overflow(phase, mul_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
357 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
358 if (type2 == TypeInt::ONE) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
359 Node* mul_result = new (phase->C) AddINode(arg1, phase->intcon(0)); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
360 return no_overflow(phase, mul_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
361 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
362 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
363 if (type1 == TypeInt::MINUS_1) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
364 return new (phase->C) NegExactINode(NULL, arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
365 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
366 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
367 if (type2 == TypeInt::MINUS_1) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
368 return new (phase->C) NegExactINode(NULL, arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
369 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
370 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
371 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
372 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
373 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
374 Node* MulExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
375 Node* arg1 = in(1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
376 Node* arg2 = in(2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
377 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
378 const Type* type1 = phase->type(arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
379 const Type* type2 = phase->type(arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
380 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
381 if (type1 != Type::TOP && type1->singleton() && |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
382 type2 != Type::TOP && type2->singleton()) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
383 jlong val1 = arg1->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
384 jlong val2 = arg2->get_long(); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
385 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
386 jlong result = val1 * val2; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
387 jlong ax = (val1 < 0 ? -val1 : val1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
388 jlong ay = (val2 < 0 ? -val2 : val2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
389 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
390 bool overflow = false; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
391 if ((ax | ay) & CONST64(0xFFFFFFFF00000000)) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
392 // potential overflow if any bit in upper 32 bits are set |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
393 if ((val1 == min_jlong && val2 == -1) || (val2 == min_jlong && val1 == -1)) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
394 // -1 * Long.MIN_VALUE will overflow |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
395 overflow = true; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
396 } else if (val2 != 0 && (result / val2 != val1)) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
397 overflow = true; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
398 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
399 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
400 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
401 if (!overflow) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
402 Node* mul_result = ConLNode::make(phase->C, result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
403 return no_overflow(phase, mul_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
404 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
405 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
406 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
407 if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
408 return no_overflow(phase, ConLNode::make(phase->C, 0)); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
409 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
410 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
411 if (type1 == TypeLong::ONE) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
412 Node* mul_result = new (phase->C) AddLNode(arg2, phase->longcon(0)); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
413 return no_overflow(phase, mul_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
414 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
415 if (type2 == TypeLong::ONE) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
416 Node* mul_result = new (phase->C) AddLNode(arg1, phase->longcon(0)); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
417 return no_overflow(phase, mul_result); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
418 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
419 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
420 if (type1 == TypeLong::MINUS_1) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
421 return new (phase->C) NegExactLNode(NULL, arg2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
422 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
423 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
424 if (type2 == TypeLong::MINUS_1) { |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
425 return new (phase->C) NegExactLNode(NULL, arg1); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
426 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
427 |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
428 return NULL; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
429 } |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12888
diff
changeset
|
430 |