annotate src/share/vm/opto/addnode.cpp @ 293:c3e045194476

6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type") Summary: fixed few addP node type and narrow oop type problems. Reviewed-by: rasbold, never
author kvn
date Fri, 01 Aug 2008 10:06:45 -0700
parents d1605aabd0a1
children af945ba2e739
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 99
diff changeset
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Portions of code courtesy of Clifford Click
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #include "incls/_addnode.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #define MAXFLOAT ((float)3.40282346638528860e+38)
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // Classic Add functionality. This covers all the usual 'add' behaviors for
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // an algebraic ring. Add-integer, add-float, add-double, and binary-or are
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // all inherited from this class. The various identity values are supplied
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // by virtual functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //------------------------------hash-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Hash function over AddNodes. Needs to be commutative; i.e., I swap
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // (commute) inputs to AddNodes willy-nilly so the hash function must return
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // the same value in the presence of edge swapping.
a61af66fc99e Initial load
duke
parents:
diff changeset
43 uint AddNode::hash() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 return (uintptr_t)in(1) + (uintptr_t)in(2) + Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // If either input is a constant 0, return the other input.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 Node *AddNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 const Type *zero = add_id(); // The additive identity
a61af66fc99e Initial load
duke
parents:
diff changeset
51 if( phase->type( in(1) )->higher_equal( zero ) ) return in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 if( phase->type( in(2) )->higher_equal( zero ) ) return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 //------------------------------commute----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Commute operands to move loads and constants to the right.
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static bool commute( Node *add, int con_left, int con_right ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 Node *in1 = add->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 Node *in2 = add->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Convert "1+x" into "x+1".
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // Right is a constant; leave it
a61af66fc99e Initial load
duke
parents:
diff changeset
64 if( con_right ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Left is a constant; move it right.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 if( con_left ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 add->swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Convert "Load+x" into "x+Load".
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Now check for loads
99
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
73 if (in2->is_Load()) {
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
74 if (!in1->is_Load()) {
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
75 // already x+Load to return
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
76 return false;
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
77 }
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
78 // both are loads, so fall through to sort inputs by idx
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
79 } else if( in1->is_Load() ) {
8a4ef4e001d3 6680594: Load + Load isn't canonicalized leading to missed GVN opportunities
never
parents: 32
diff changeset
80 // Left is a Load and Right is not; move it right.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81 add->swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 }
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 PhiNode *phi;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Check for tight loop increments: Loop-phi of Add of loop-phi
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if( in1->is_Phi() && (phi = in1->as_Phi()) && !phi->is_copy() && phi->region()->is_Loop() && phi->in(2)==add)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 if( in2->is_Phi() && (phi = in2->as_Phi()) && !phi->is_copy() && phi->region()->is_Loop() && phi->in(2)==add){
a61af66fc99e Initial load
duke
parents:
diff changeset
90 add->swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Otherwise, sort inputs (commutativity) to help value numbering.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if( in1->_idx > in2->_idx ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 add->swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 //------------------------------Idealize---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // If we get here, we assume we are associative!
a61af66fc99e Initial load
duke
parents:
diff changeset
104 Node *AddNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
106 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
107 int con_left = t1->singleton();
a61af66fc99e Initial load
duke
parents:
diff changeset
108 int con_right = t2->singleton();
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Check for commutative operation desired
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if( commute(this,con_left,con_right) ) return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 AddNode *progress = NULL; // Progress flag
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Convert "(x+1)+2" into "x+(1+2)". If the right input is a
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // constant, and the left input is an add of a constant, flatten the
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // expression tree.
a61af66fc99e Initial load
duke
parents:
diff changeset
118 Node *add1 = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 Node *add2 = in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 int add1_op = add1->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 int this_op = Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if( con_right && t2 != Type::TOP && // Right input is a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
123 add1_op == this_op ) { // Left input is an Add?
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Type of left _in right input
a61af66fc99e Initial load
duke
parents:
diff changeset
126 const Type *t12 = phase->type( add1->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
127 if( t12->singleton() && t12 != Type::TOP ) { // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Check for rare case of closed data cycle which can happen inside
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // unreachable loops. In these cases the computation is undefined.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
131 Node *add11 = add1->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int add11_op = add11->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
133 if( (add1 == add1->in(1))
a61af66fc99e Initial load
duke
parents:
diff changeset
134 || (add11_op == this_op && add11->in(1) == add1) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 assert(false, "dead loop in AddNode::Ideal");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // The Add of the flattened expression
a61af66fc99e Initial load
duke
parents:
diff changeset
139 Node *x1 = add1->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 Node *x2 = phase->makecon( add1->as_Add()->add_ring( t2, t12 ));
a61af66fc99e Initial load
duke
parents:
diff changeset
141 PhaseIterGVN *igvn = phase->is_IterGVN();
a61af66fc99e Initial load
duke
parents:
diff changeset
142 if( igvn ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 set_req_X(2,x2,igvn);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 set_req_X(1,x1,igvn);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 set_req(2,x2);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 set_req(1,x1);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 progress = this; // Made progress
a61af66fc99e Initial load
duke
parents:
diff changeset
150 add1 = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 add1_op = add1->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // Convert "(x+1)+y" into "(x+y)+1". Push constants down the expression tree.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 if( add1_op == this_op && !con_right ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 Node *a12 = add1->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 const Type *t12 = phase->type( a12 );
a61af66fc99e Initial load
duke
parents:
diff changeset
159 if( t12->singleton() && t12 != Type::TOP && (add1 != add1->in(1)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 add2 = add1->clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
161 add2->set_req(2, in(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
162 add2 = phase->transform(add2);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 set_req(1, add2);
a61af66fc99e Initial load
duke
parents:
diff changeset
164 set_req(2, a12);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 progress = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 add2 = a12;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // Convert "x+(y+1)" into "(x+y)+1". Push constants down the expression tree.
a61af66fc99e Initial load
duke
parents:
diff changeset
171 int add2_op = add2->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
172 if( add2_op == this_op && !con_left ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 Node *a22 = add2->in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
174 const Type *t22 = phase->type( a22 );
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if( t22->singleton() && t22 != Type::TOP && (add2 != add2->in(1)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Node *addx = add2->clone();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 addx->set_req(1, in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
178 addx->set_req(2, add2->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
179 addx = phase->transform(addx);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 set_req(1, addx);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 set_req(2, a22);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 progress = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return progress;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 //------------------------------Value-----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // An add node sums it's two _in. If one input is an RSD, we must mixin
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // the other input's symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
192 const Type *AddNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
194 const Type *t1 = phase->type( in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
195 const Type *t2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Either input is BOTTOM ==> the result is the local BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
200 const Type *bot = bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 if( (t1 == bot) || (t2 == bot) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
202 (t1 == Type::BOTTOM) || (t2 == Type::BOTTOM) )
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return bot;
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Check for an addition involving the additive identity
a61af66fc99e Initial load
duke
parents:
diff changeset
206 const Type *tadd = add_of_identity( t1, t2 );
a61af66fc99e Initial load
duke
parents:
diff changeset
207 if( tadd ) return tadd;
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return add_ring(t1,t2); // Local flavor of type addition
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 //------------------------------add_identity-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
213 // Check for addition of the identity
a61af66fc99e Initial load
duke
parents:
diff changeset
214 const Type *AddNode::add_of_identity( const Type *t1, const Type *t2 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
215 const Type *zero = add_id(); // The additive identity
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if( t1->higher_equal( zero ) ) return t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
217 if( t2->higher_equal( zero ) ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
224 //------------------------------Idealize---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
225 Node *AddINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
226 int op1 = in(1)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 int op2 = in(2)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // Fold (con1-x)+con2 into (con1+con2)-x
a61af66fc99e Initial load
duke
parents:
diff changeset
229 if( op1 == Op_SubI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 const Type *t_sub1 = phase->type( in(1)->in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
231 const Type *t_2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP )
a61af66fc99e Initial load
duke
parents:
diff changeset
233 return new (phase->C, 3) SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ),
a61af66fc99e Initial load
duke
parents:
diff changeset
234 in(1)->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)"
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if( op2 == Op_SubI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Check for dead cycle: d = (a-b)+(c-d)
a61af66fc99e Initial load
duke
parents:
diff changeset
238 assert( in(1)->in(2) != this && in(2)->in(2) != this,
a61af66fc99e Initial load
duke
parents:
diff changeset
239 "dead loop in AddINode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
240 Node *sub = new (phase->C, 3) SubINode(NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 sub->init_req(1, phase->transform(new (phase->C, 3) AddINode(in(1)->in(1), in(2)->in(1) ) ));
a61af66fc99e Initial load
duke
parents:
diff changeset
242 sub->init_req(2, phase->transform(new (phase->C, 3) AddINode(in(1)->in(2), in(2)->in(2) ) ));
a61af66fc99e Initial load
duke
parents:
diff changeset
243 return sub;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // Convert "x+(0-y)" into "(x-y)"
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if( op2 == Op_SubI && phase->type(in(2)->in(1)) == TypeInt::ZERO )
a61af66fc99e Initial load
duke
parents:
diff changeset
249 return new (phase->C, 3) SubINode(in(1), in(2)->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // Convert "(0-y)+x" into "(x-y)"
a61af66fc99e Initial load
duke
parents:
diff changeset
252 if( op1 == Op_SubI && phase->type(in(1)->in(1)) == TypeInt::ZERO )
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return new (phase->C, 3) SubINode( in(2), in(1)->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // Convert (x>>>z)+y into (x+(y<<z))>>>z for small constant z and y.
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Helps with array allocation math constant folding
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // See 4790063:
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // Unrestricted transformation is unsafe for some runtime values of 'x'
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // ( x == 0, z == 1, y == -1 ) fails
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // ( x == -5, z == 1, y == 1 ) fails
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Transform works for small z and small negative y when the addition
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // (x + (y << z)) does not cross zero.
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Implement support for negative y and (x >= -(y << z))
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // Have not observed cases where type information exists to support
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // positive y and (x <= -(y << z))
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if( op1 == Op_URShiftI && op2 == Op_ConI &&
a61af66fc99e Initial load
duke
parents:
diff changeset
267 in(1)->in(2)->Opcode() == Op_ConI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 jint z = phase->type( in(1)->in(2) )->is_int()->get_con() & 0x1f; // only least significant 5 bits matter
a61af66fc99e Initial load
duke
parents:
diff changeset
269 jint y = phase->type( in(2) )->is_int()->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 if( z < 5 && -5 < y && y < 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 const Type *t_in11 = phase->type(in(1)->in(1));
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 Node *a = phase->transform( new (phase->C, 3) AddINode( in(1)->in(1), phase->intcon(y<<z) ) );
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return new (phase->C, 3) URShiftINode( a, in(1)->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 return AddNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // Fold (x-y)+y OR y+(x-y) into x
a61af66fc99e Initial load
duke
parents:
diff changeset
286 Node *AddINode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if( in(1)->Opcode() == Op_SubI && phase->eqv(in(1)->in(2),in(2)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290 else if( in(2)->Opcode() == Op_SubI && phase->eqv(in(2)->in(2),in(1)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
291 return in(2)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 return AddNode::Identity(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // Supplied function returns the sum of the inputs. Guaranteed never
a61af66fc99e Initial load
duke
parents:
diff changeset
299 // to be passed a TOP or BOTTOM type, these are filtered out by
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
301 const Type *AddINode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
303 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
304 int lo = r0->_lo + r1->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 int hi = r0->_hi + r1->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 if( !(r0->is_con() && r1->is_con()) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // Not both constants, compute approximate result
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 lo = min_jint; hi = max_jint; // Underflow on the low side
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
312 lo = min_jint; hi = max_jint; // Overflow on the high side
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314 if( lo > hi ) { // Handle overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
315 lo = min_jint; hi = max_jint;
a61af66fc99e Initial load
duke
parents:
diff changeset
316 }
a61af66fc99e Initial load
duke
parents:
diff changeset
317 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
318 // both constants, compute precise result using 'lo' and 'hi'
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // Semantics define overflow and underflow for integer addition
a61af66fc99e Initial load
duke
parents:
diff changeset
320 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322 return TypeInt::make( lo, hi, MAX2(r0->_widen,r1->_widen) );
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
327 //------------------------------Idealize---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
328 Node *AddLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
329 int op1 = in(1)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
330 int op2 = in(2)->Opcode();
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // Fold (con1-x)+con2 into (con1+con2)-x
a61af66fc99e Initial load
duke
parents:
diff changeset
332 if( op1 == Op_SubL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 const Type *t_sub1 = phase->type( in(1)->in(1) );
a61af66fc99e Initial load
duke
parents:
diff changeset
334 const Type *t_2 = phase->type( in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
335 if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP )
a61af66fc99e Initial load
duke
parents:
diff changeset
336 return new (phase->C, 3) SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ),
a61af66fc99e Initial load
duke
parents:
diff changeset
337 in(1)->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
338 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)"
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if( op2 == Op_SubL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // Check for dead cycle: d = (a-b)+(c-d)
a61af66fc99e Initial load
duke
parents:
diff changeset
341 assert( in(1)->in(2) != this && in(2)->in(2) != this,
a61af66fc99e Initial load
duke
parents:
diff changeset
342 "dead loop in AddLNode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
343 Node *sub = new (phase->C, 3) SubLNode(NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
344 sub->init_req(1, phase->transform(new (phase->C, 3) AddLNode(in(1)->in(1), in(2)->in(1) ) ));
a61af66fc99e Initial load
duke
parents:
diff changeset
345 sub->init_req(2, phase->transform(new (phase->C, 3) AddLNode(in(1)->in(2), in(2)->in(2) ) ));
a61af66fc99e Initial load
duke
parents:
diff changeset
346 return sub;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 // Convert "x+(0-y)" into "(x-y)"
a61af66fc99e Initial load
duke
parents:
diff changeset
351 if( op2 == Op_SubL && phase->type(in(2)->in(1)) == TypeLong::ZERO )
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return new (phase->C, 3) SubLNode(in(1), in(2)->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // Convert "X+X+X+X+X...+X+Y" into "k*X+Y" or really convert "X+(X+Y)"
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // into "(X<<1)+Y" and let shift-folding happen.
a61af66fc99e Initial load
duke
parents:
diff changeset
356 if( op2 == Op_AddL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
357 in(2)->in(1) == in(1) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
358 op1 != Op_ConL &&
a61af66fc99e Initial load
duke
parents:
diff changeset
359 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
360 Node *shift = phase->transform(new (phase->C, 3) LShiftLNode(in(1),phase->intcon(1)));
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return new (phase->C, 3) AddLNode(shift,in(2)->in(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364 return AddNode::Ideal(phase, can_reshape);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // Fold (x-y)+y OR y+(x-y) into x
a61af66fc99e Initial load
duke
parents:
diff changeset
370 Node *AddLNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 if( in(1)->Opcode() == Op_SubL && phase->eqv(in(1)->in(2),in(2)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 return in(1)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
373 }
a61af66fc99e Initial load
duke
parents:
diff changeset
374 else if( in(2)->Opcode() == Op_SubL && phase->eqv(in(2)->in(2),in(1)) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
375 return in(2)->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }
a61af66fc99e Initial load
duke
parents:
diff changeset
377 return AddNode::Identity(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
378 }
a61af66fc99e Initial load
duke
parents:
diff changeset
379
a61af66fc99e Initial load
duke
parents:
diff changeset
380
a61af66fc99e Initial load
duke
parents:
diff changeset
381 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
382 // Supplied function returns the sum of the inputs. Guaranteed never
a61af66fc99e Initial load
duke
parents:
diff changeset
383 // to be passed a TOP or BOTTOM type, these are filtered out by
a61af66fc99e Initial load
duke
parents:
diff changeset
384 // pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
385 const Type *AddLNode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
386 const TypeLong *r0 = t0->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
387 const TypeLong *r1 = t1->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
388 jlong lo = r0->_lo + r1->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
389 jlong hi = r0->_hi + r1->_hi;
a61af66fc99e Initial load
duke
parents:
diff changeset
390 if( !(r0->is_con() && r1->is_con()) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
391 // Not both constants, compute approximate result
a61af66fc99e Initial load
duke
parents:
diff changeset
392 if( (r0->_lo & r1->_lo) < 0 && lo >= 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 lo =min_jlong; hi = max_jlong; // Underflow on the low side
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395 if( (~(r0->_hi | r1->_hi)) < 0 && hi < 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 lo = min_jlong; hi = max_jlong; // Overflow on the high side
a61af66fc99e Initial load
duke
parents:
diff changeset
397 }
a61af66fc99e Initial load
duke
parents:
diff changeset
398 if( lo > hi ) { // Handle overflow
a61af66fc99e Initial load
duke
parents:
diff changeset
399 lo = min_jlong; hi = max_jlong;
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 // both constants, compute precise result using 'lo' and 'hi'
a61af66fc99e Initial load
duke
parents:
diff changeset
403 // Semantics define overflow and underflow for integer addition
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // as expected. In particular: 0x80000000 + 0x80000000 --> 0x0
a61af66fc99e Initial load
duke
parents:
diff changeset
405 }
a61af66fc99e Initial load
duke
parents:
diff changeset
406 return TypeLong::make( lo, hi, MAX2(r0->_widen,r1->_widen) );
a61af66fc99e Initial load
duke
parents:
diff changeset
407 }
a61af66fc99e Initial load
duke
parents:
diff changeset
408
a61af66fc99e Initial load
duke
parents:
diff changeset
409
a61af66fc99e Initial load
duke
parents:
diff changeset
410 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
411 //------------------------------add_of_identity--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
412 // Check for addition of the identity
a61af66fc99e Initial load
duke
parents:
diff changeset
413 const Type *AddFNode::add_of_identity( const Type *t1, const Type *t2 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
414 // x ADD 0 should return x unless 'x' is a -zero
a61af66fc99e Initial load
duke
parents:
diff changeset
415 //
a61af66fc99e Initial load
duke
parents:
diff changeset
416 // const Type *zero = add_id(); // The additive identity
a61af66fc99e Initial load
duke
parents:
diff changeset
417 // jfloat f1 = t1->getf();
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // jfloat f2 = t2->getf();
a61af66fc99e Initial load
duke
parents:
diff changeset
419 //
a61af66fc99e Initial load
duke
parents:
diff changeset
420 // if( t1->higher_equal( zero ) ) return t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 // if( t2->higher_equal( zero ) ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
422
a61af66fc99e Initial load
duke
parents:
diff changeset
423 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425
a61af66fc99e Initial load
duke
parents:
diff changeset
426 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
427 // Supplied function returns the sum of the inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // This also type-checks the inputs for sanity. Guaranteed never to
a61af66fc99e Initial load
duke
parents:
diff changeset
429 // be passed a TOP or BOTTOM type, these are filtered out by pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
430 const Type *AddFNode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
431 // We must be adding 2 float constants.
a61af66fc99e Initial load
duke
parents:
diff changeset
432 return TypeF::make( t0->getf() + t1->getf() );
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434
a61af66fc99e Initial load
duke
parents:
diff changeset
435 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
436 Node *AddFNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
437 if( IdealizedNumerics && !phase->C->method()->is_strict() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 return AddNode::Ideal(phase, can_reshape); // commutative and associative transforms
a61af66fc99e Initial load
duke
parents:
diff changeset
439 }
a61af66fc99e Initial load
duke
parents:
diff changeset
440
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // Floating point additions are not associative because of boundary conditions (infinity)
a61af66fc99e Initial load
duke
parents:
diff changeset
442 return commute(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
443 phase->type( in(1) )->singleton(),
a61af66fc99e Initial load
duke
parents:
diff changeset
444 phase->type( in(2) )->singleton() ) ? this : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
445 }
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447
a61af66fc99e Initial load
duke
parents:
diff changeset
448 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
449 //------------------------------add_of_identity--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // Check for addition of the identity
a61af66fc99e Initial load
duke
parents:
diff changeset
451 const Type *AddDNode::add_of_identity( const Type *t1, const Type *t2 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
452 // x ADD 0 should return x unless 'x' is a -zero
a61af66fc99e Initial load
duke
parents:
diff changeset
453 //
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // const Type *zero = add_id(); // The additive identity
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // jfloat f1 = t1->getf();
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // jfloat f2 = t2->getf();
a61af66fc99e Initial load
duke
parents:
diff changeset
457 //
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // if( t1->higher_equal( zero ) ) return t2;
a61af66fc99e Initial load
duke
parents:
diff changeset
459 // if( t2->higher_equal( zero ) ) return t1;
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
462 }
a61af66fc99e Initial load
duke
parents:
diff changeset
463 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
464 // Supplied function returns the sum of the inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
465 // This also type-checks the inputs for sanity. Guaranteed never to
a61af66fc99e Initial load
duke
parents:
diff changeset
466 // be passed a TOP or BOTTOM type, these are filtered out by pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
467 const Type *AddDNode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
468 // We must be adding 2 double constants.
a61af66fc99e Initial load
duke
parents:
diff changeset
469 return TypeD::make( t0->getd() + t1->getd() );
a61af66fc99e Initial load
duke
parents:
diff changeset
470 }
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 //------------------------------Ideal------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
473 Node *AddDNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 if( IdealizedNumerics && !phase->C->method()->is_strict() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
475 return AddNode::Ideal(phase, can_reshape); // commutative and associative transforms
a61af66fc99e Initial load
duke
parents:
diff changeset
476 }
a61af66fc99e Initial load
duke
parents:
diff changeset
477
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // Floating point additions are not associative because of boundary conditions (infinity)
a61af66fc99e Initial load
duke
parents:
diff changeset
479 return commute(this,
a61af66fc99e Initial load
duke
parents:
diff changeset
480 phase->type( in(1) )->singleton(),
a61af66fc99e Initial load
duke
parents:
diff changeset
481 phase->type( in(2) )->singleton() ) ? this : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
486 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // If one input is a constant 0, return the other input.
a61af66fc99e Initial load
duke
parents:
diff changeset
488 Node *AddPNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
489 return ( phase->type( in(Offset) )->higher_equal( TypeX_ZERO ) ) ? in(Address) : this;
a61af66fc99e Initial load
duke
parents:
diff changeset
490 }
a61af66fc99e Initial load
duke
parents:
diff changeset
491
a61af66fc99e Initial load
duke
parents:
diff changeset
492 //------------------------------Idealize---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
493 Node *AddPNode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
494 // Bail out if dead inputs
a61af66fc99e Initial load
duke
parents:
diff changeset
495 if( phase->type( in(Address) ) == Type::TOP ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 // If the left input is an add of a constant, flatten the expression tree.
a61af66fc99e Initial load
duke
parents:
diff changeset
498 const Node *n = in(Address);
a61af66fc99e Initial load
duke
parents:
diff changeset
499 if (n->is_AddP() && n->in(Base) == in(Base)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
500 const AddPNode *addp = n->as_AddP(); // Left input is an AddP
a61af66fc99e Initial load
duke
parents:
diff changeset
501 assert( !addp->in(Address)->is_AddP() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
502 addp->in(Address)->as_AddP() != addp,
a61af66fc99e Initial load
duke
parents:
diff changeset
503 "dead loop in AddPNode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // Type of left input's right input
a61af66fc99e Initial load
duke
parents:
diff changeset
505 const Type *t = phase->type( addp->in(Offset) );
a61af66fc99e Initial load
duke
parents:
diff changeset
506 if( t == Type::TOP ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
507 const TypeX *t12 = t->is_intptr_t();
a61af66fc99e Initial load
duke
parents:
diff changeset
508 if( t12->is_con() ) { // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
509 // If the right input is a constant, combine constants
a61af66fc99e Initial load
duke
parents:
diff changeset
510 const Type *temp_t2 = phase->type( in(Offset) );
a61af66fc99e Initial load
duke
parents:
diff changeset
511 if( temp_t2 == Type::TOP ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
512 const TypeX *t2 = temp_t2->is_intptr_t();
32
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
513 Node* address;
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
514 Node* offset;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
515 if( t2->is_con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // The Add of the flattened expression
32
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
517 address = addp->in(Address);
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
518 offset = phase->MakeConX(t2->get_con() + t12->get_con());
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
519 } else {
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
520 // Else move the constant to the right. ((A+con)+B) into ((A+B)+con)
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
521 address = phase->transform(new (phase->C, 4) AddPNode(in(Base),addp->in(Address),in(Offset)));
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
522 offset = addp->in(Offset);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
523 }
32
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
524 PhaseIterGVN *igvn = phase->is_IterGVN();
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
525 if( igvn ) {
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
526 set_req_X(Address,address,igvn);
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
527 set_req_X(Offset,offset,igvn);
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
528 } else {
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
529 set_req(Address,address);
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
530 set_req(Offset,offset);
4d428c5b4cb3 6667573: Use set_req_X() in AddPNode::Ideal() for Iterative GVN
kvn
parents: 17
diff changeset
531 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
532 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
533 }
a61af66fc99e Initial load
duke
parents:
diff changeset
534 }
a61af66fc99e Initial load
duke
parents:
diff changeset
535
a61af66fc99e Initial load
duke
parents:
diff changeset
536 // Raw pointers?
a61af66fc99e Initial load
duke
parents:
diff changeset
537 if( in(Base)->bottom_type() == Type::TOP ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 // If this is a NULL+long form (from unsafe accesses), switch to a rawptr.
a61af66fc99e Initial load
duke
parents:
diff changeset
539 if (phase->type(in(Address)) == TypePtr::NULL_PTR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
540 Node* offset = in(Offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
541 return new (phase->C, 2) CastX2PNode(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
544
a61af66fc99e Initial load
duke
parents:
diff changeset
545 // If the right is an add of a constant, push the offset down.
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // Convert: (ptr + (offset+con)) into (ptr+offset)+con.
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // The idea is to merge array_base+scaled_index groups together,
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // and only have different constant offsets from the same base.
a61af66fc99e Initial load
duke
parents:
diff changeset
549 const Node *add = in(Offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
550 if( add->Opcode() == Op_AddX && add->in(1) != add ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 const Type *t22 = phase->type( add->in(2) );
a61af66fc99e Initial load
duke
parents:
diff changeset
552 if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
553 set_req(Address, phase->transform(new (phase->C, 4) AddPNode(in(Base),in(Address),add->in(1))));
a61af66fc99e Initial load
duke
parents:
diff changeset
554 set_req(Offset, add->in(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
555 return this; // Made progress
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }
a61af66fc99e Initial load
duke
parents:
diff changeset
557 }
a61af66fc99e Initial load
duke
parents:
diff changeset
558
a61af66fc99e Initial load
duke
parents:
diff changeset
559 return NULL; // No progress
a61af66fc99e Initial load
duke
parents:
diff changeset
560 }
a61af66fc99e Initial load
duke
parents:
diff changeset
561
a61af66fc99e Initial load
duke
parents:
diff changeset
562 //------------------------------bottom_type------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // Bottom-type is the pointer-type with unknown offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
564 const Type *AddPNode::bottom_type() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
565 if (in(Address) == NULL) return TypePtr::BOTTOM;
a61af66fc99e Initial load
duke
parents:
diff changeset
566 const TypePtr *tp = in(Address)->bottom_type()->isa_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
567 if( !tp ) return Type::TOP; // TOP input means TOP output
a61af66fc99e Initial load
duke
parents:
diff changeset
568 assert( in(Offset)->Opcode() != Op_ConP, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
569 const Type *t = in(Offset)->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
570 if( t == Type::TOP )
a61af66fc99e Initial load
duke
parents:
diff changeset
571 return tp->add_offset(Type::OffsetTop);
a61af66fc99e Initial load
duke
parents:
diff changeset
572 const TypeX *tx = t->is_intptr_t();
a61af66fc99e Initial load
duke
parents:
diff changeset
573 intptr_t txoffset = Type::OffsetBot;
a61af66fc99e Initial load
duke
parents:
diff changeset
574 if (tx->is_con()) { // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
575 txoffset = tx->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
576 if (txoffset != (int)txoffset)
a61af66fc99e Initial load
duke
parents:
diff changeset
577 txoffset = Type::OffsetBot; // oops: add_offset will choke on it
a61af66fc99e Initial load
duke
parents:
diff changeset
578 }
a61af66fc99e Initial load
duke
parents:
diff changeset
579 return tp->add_offset(txoffset);
a61af66fc99e Initial load
duke
parents:
diff changeset
580 }
a61af66fc99e Initial load
duke
parents:
diff changeset
581
a61af66fc99e Initial load
duke
parents:
diff changeset
582 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
583 const Type *AddPNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
584 // Either input is TOP ==> the result is TOP
a61af66fc99e Initial load
duke
parents:
diff changeset
585 const Type *t1 = phase->type( in(Address) );
a61af66fc99e Initial load
duke
parents:
diff changeset
586 const Type *t2 = phase->type( in(Offset) );
a61af66fc99e Initial load
duke
parents:
diff changeset
587 if( t1 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
588 if( t2 == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
589
a61af66fc99e Initial load
duke
parents:
diff changeset
590 // Left input is a pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
591 const TypePtr *p1 = t1->isa_ptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
592 // Right input is an int
a61af66fc99e Initial load
duke
parents:
diff changeset
593 const TypeX *p2 = t2->is_intptr_t();
a61af66fc99e Initial load
duke
parents:
diff changeset
594 // Add 'em
a61af66fc99e Initial load
duke
parents:
diff changeset
595 intptr_t p2offset = Type::OffsetBot;
a61af66fc99e Initial load
duke
parents:
diff changeset
596 if (p2->is_con()) { // Left input is an add of a constant?
a61af66fc99e Initial load
duke
parents:
diff changeset
597 p2offset = p2->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
598 if (p2offset != (int)p2offset)
a61af66fc99e Initial load
duke
parents:
diff changeset
599 p2offset = Type::OffsetBot; // oops: add_offset will choke on it
a61af66fc99e Initial load
duke
parents:
diff changeset
600 }
a61af66fc99e Initial load
duke
parents:
diff changeset
601 return p1->add_offset(p2offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
602 }
a61af66fc99e Initial load
duke
parents:
diff changeset
603
a61af66fc99e Initial load
duke
parents:
diff changeset
604 //------------------------Ideal_base_and_offset--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
605 // Split an oop pointer into a base and offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
606 // (The offset might be Type::OffsetBot in the case of an array.)
a61af66fc99e Initial load
duke
parents:
diff changeset
607 // Return the base, or NULL if failure.
a61af66fc99e Initial load
duke
parents:
diff changeset
608 Node* AddPNode::Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
a61af66fc99e Initial load
duke
parents:
diff changeset
609 // second return value:
a61af66fc99e Initial load
duke
parents:
diff changeset
610 intptr_t& offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
611 if (ptr->is_AddP()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
612 Node* base = ptr->in(AddPNode::Base);
a61af66fc99e Initial load
duke
parents:
diff changeset
613 Node* addr = ptr->in(AddPNode::Address);
a61af66fc99e Initial load
duke
parents:
diff changeset
614 Node* offs = ptr->in(AddPNode::Offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
615 if (base == addr || base->is_top()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
616 offset = phase->find_intptr_t_con(offs, Type::OffsetBot);
a61af66fc99e Initial load
duke
parents:
diff changeset
617 if (offset != Type::OffsetBot) {
a61af66fc99e Initial load
duke
parents:
diff changeset
618 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
619 }
a61af66fc99e Initial load
duke
parents:
diff changeset
620 }
a61af66fc99e Initial load
duke
parents:
diff changeset
621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
622 offset = Type::OffsetBot;
a61af66fc99e Initial load
duke
parents:
diff changeset
623 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
624 }
a61af66fc99e Initial load
duke
parents:
diff changeset
625
17
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
626 //------------------------------unpack_offsets----------------------------------
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
627 // Collect the AddP offset values into the elements array, giving up
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
628 // if there are more than length.
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
629 int AddPNode::unpack_offsets(Node* elements[], int length) {
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
630 int count = 0;
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
631 Node* addr = this;
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
632 Node* base = addr->in(AddPNode::Base);
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
633 while (addr->is_AddP()) {
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
634 if (addr->in(AddPNode::Base) != base) {
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
635 // give up
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
636 return -1;
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
637 }
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
638 elements[count++] = addr->in(AddPNode::Offset);
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
639 if (count == length) {
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
640 // give up
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
641 return -1;
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
642 }
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
643 addr = addr->in(AddPNode::Address);
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
644 }
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
645 return count;
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
646 }
ff5961f4c095 6395208: Elide autoboxing for calls to HashMap.get(int) and HashMap.get(long)
never
parents: 0
diff changeset
647
0
a61af66fc99e Initial load
duke
parents:
diff changeset
648 //------------------------------match_edge-------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
649 // Do we Match on this edge index or not? Do not match base pointer edge
a61af66fc99e Initial load
duke
parents:
diff changeset
650 uint AddPNode::match_edge(uint idx) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
651 return idx > Base;
a61af66fc99e Initial load
duke
parents:
diff changeset
652 }
a61af66fc99e Initial load
duke
parents:
diff changeset
653
a61af66fc99e Initial load
duke
parents:
diff changeset
654 //---------------------------mach_bottom_type----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
655 // Utility function for use by ADLC. Implements bottom_type for matched AddP.
a61af66fc99e Initial load
duke
parents:
diff changeset
656 const Type *AddPNode::mach_bottom_type( const MachNode* n) {
a61af66fc99e Initial load
duke
parents:
diff changeset
657 Node* base = n->in(Base);
a61af66fc99e Initial load
duke
parents:
diff changeset
658 const Type *t = base->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
659 if ( t == Type::TOP ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
660 // an untyped pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
661 return TypeRawPtr::BOTTOM;
a61af66fc99e Initial load
duke
parents:
diff changeset
662 }
a61af66fc99e Initial load
duke
parents:
diff changeset
663 const TypePtr* tp = t->isa_oopptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
664 if ( tp == NULL ) return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
665 if ( tp->_offset == TypePtr::OffsetBot ) return tp;
a61af66fc99e Initial load
duke
parents:
diff changeset
666
a61af66fc99e Initial load
duke
parents:
diff changeset
667 // We must carefully add up the various offsets...
a61af66fc99e Initial load
duke
parents:
diff changeset
668 intptr_t offset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
669 const TypePtr* tptr = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
670
a61af66fc99e Initial load
duke
parents:
diff changeset
671 uint numopnds = n->num_opnds();
a61af66fc99e Initial load
duke
parents:
diff changeset
672 uint index = n->oper_input_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
673 for ( uint i = 1; i < numopnds; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
674 MachOper *opnd = n->_opnds[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
675 // Check for any interesting operand info.
a61af66fc99e Initial load
duke
parents:
diff changeset
676 // In particular, check for both memory and non-memory operands.
a61af66fc99e Initial load
duke
parents:
diff changeset
677 // %%%%% Clean this up: use xadd_offset
a61af66fc99e Initial load
duke
parents:
diff changeset
678 int con = opnd->constant();
a61af66fc99e Initial load
duke
parents:
diff changeset
679 if ( con == TypePtr::OffsetBot ) goto bottom_out;
a61af66fc99e Initial load
duke
parents:
diff changeset
680 offset += con;
a61af66fc99e Initial load
duke
parents:
diff changeset
681 con = opnd->constant_disp();
a61af66fc99e Initial load
duke
parents:
diff changeset
682 if ( con == TypePtr::OffsetBot ) goto bottom_out;
a61af66fc99e Initial load
duke
parents:
diff changeset
683 offset += con;
a61af66fc99e Initial load
duke
parents:
diff changeset
684 if( opnd->scale() != 0 ) goto bottom_out;
a61af66fc99e Initial load
duke
parents:
diff changeset
685
a61af66fc99e Initial load
duke
parents:
diff changeset
686 // Check each operand input edge. Find the 1 allowed pointer
a61af66fc99e Initial load
duke
parents:
diff changeset
687 // edge. Other edges must be index edges; track exact constant
a61af66fc99e Initial load
duke
parents:
diff changeset
688 // inputs and otherwise assume the worst.
a61af66fc99e Initial load
duke
parents:
diff changeset
689 for ( uint j = opnd->num_edges(); j > 0; j-- ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
690 Node* edge = n->in(index++);
a61af66fc99e Initial load
duke
parents:
diff changeset
691 const Type* et = edge->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
692 const TypeX* eti = et->isa_intptr_t();
a61af66fc99e Initial load
duke
parents:
diff changeset
693 if ( eti == NULL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
694 // there must be one pointer among the operands
a61af66fc99e Initial load
duke
parents:
diff changeset
695 guarantee(tptr == NULL, "must be only one pointer operand");
a61af66fc99e Initial load
duke
parents:
diff changeset
696 tptr = et->isa_oopptr();
a61af66fc99e Initial load
duke
parents:
diff changeset
697 guarantee(tptr != NULL, "non-int operand must be pointer");
293
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
698 if (tptr->higher_equal(tp->add_offset(tptr->offset())))
c3e045194476 6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents: 196
diff changeset
699 tp = tptr; // Set more precise type for bailout
0
a61af66fc99e Initial load
duke
parents:
diff changeset
700 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
701 }
a61af66fc99e Initial load
duke
parents:
diff changeset
702 if ( eti->_hi != eti->_lo ) goto bottom_out;
a61af66fc99e Initial load
duke
parents:
diff changeset
703 offset += eti->_lo;
a61af66fc99e Initial load
duke
parents:
diff changeset
704 }
a61af66fc99e Initial load
duke
parents:
diff changeset
705 }
a61af66fc99e Initial load
duke
parents:
diff changeset
706 guarantee(tptr != NULL, "must be exactly one pointer operand");
a61af66fc99e Initial load
duke
parents:
diff changeset
707 return tptr->add_offset(offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
708
a61af66fc99e Initial load
duke
parents:
diff changeset
709 bottom_out:
a61af66fc99e Initial load
duke
parents:
diff changeset
710 return tp->add_offset(TypePtr::OffsetBot);
a61af66fc99e Initial load
duke
parents:
diff changeset
711 }
a61af66fc99e Initial load
duke
parents:
diff changeset
712
a61af66fc99e Initial load
duke
parents:
diff changeset
713 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
714 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
715 Node *OrINode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
716 // x | x => x
a61af66fc99e Initial load
duke
parents:
diff changeset
717 if (phase->eqv(in(1), in(2))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
718 return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
719 }
a61af66fc99e Initial load
duke
parents:
diff changeset
720
a61af66fc99e Initial load
duke
parents:
diff changeset
721 return AddNode::Identity(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
722 }
a61af66fc99e Initial load
duke
parents:
diff changeset
723
a61af66fc99e Initial load
duke
parents:
diff changeset
724 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
725 // Supplied function returns the sum of the inputs IN THE CURRENT RING. For
a61af66fc99e Initial load
duke
parents:
diff changeset
726 // the logical operations the ring's ADD is really a logical OR function.
a61af66fc99e Initial load
duke
parents:
diff changeset
727 // This also type-checks the inputs for sanity. Guaranteed never to
a61af66fc99e Initial load
duke
parents:
diff changeset
728 // be passed a TOP or BOTTOM type, these are filtered out by pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
729 const Type *OrINode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
730 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
731 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
732
a61af66fc99e Initial load
duke
parents:
diff changeset
733 // If both args are bool, can figure out better types
a61af66fc99e Initial load
duke
parents:
diff changeset
734 if ( r0 == TypeInt::BOOL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
735 if ( r1 == TypeInt::ONE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
736 return TypeInt::ONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
737 } else if ( r1 == TypeInt::BOOL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
738 return TypeInt::BOOL;
a61af66fc99e Initial load
duke
parents:
diff changeset
739 }
a61af66fc99e Initial load
duke
parents:
diff changeset
740 } else if ( r0 == TypeInt::ONE ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
741 if ( r1 == TypeInt::BOOL ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
742 return TypeInt::ONE;
a61af66fc99e Initial load
duke
parents:
diff changeset
743 }
a61af66fc99e Initial load
duke
parents:
diff changeset
744 }
a61af66fc99e Initial load
duke
parents:
diff changeset
745
a61af66fc99e Initial load
duke
parents:
diff changeset
746 // If either input is not a constant, just return all integers.
a61af66fc99e Initial load
duke
parents:
diff changeset
747 if( !r0->is_con() || !r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
748 return TypeInt::INT; // Any integer, but still no symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
749
a61af66fc99e Initial load
duke
parents:
diff changeset
750 // Otherwise just OR them bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
751 return TypeInt::make( r0->get_con() | r1->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
752 }
a61af66fc99e Initial load
duke
parents:
diff changeset
753
a61af66fc99e Initial load
duke
parents:
diff changeset
754 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
755 //------------------------------Identity---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
756 Node *OrLNode::Identity( PhaseTransform *phase ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
757 // x | x => x
a61af66fc99e Initial load
duke
parents:
diff changeset
758 if (phase->eqv(in(1), in(2))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
759 return in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
760 }
a61af66fc99e Initial load
duke
parents:
diff changeset
761
a61af66fc99e Initial load
duke
parents:
diff changeset
762 return AddNode::Identity(phase);
a61af66fc99e Initial load
duke
parents:
diff changeset
763 }
a61af66fc99e Initial load
duke
parents:
diff changeset
764
a61af66fc99e Initial load
duke
parents:
diff changeset
765 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
766 const Type *OrLNode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
767 const TypeLong *r0 = t0->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
768 const TypeLong *r1 = t1->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
769
a61af66fc99e Initial load
duke
parents:
diff changeset
770 // If either input is not a constant, just return all integers.
a61af66fc99e Initial load
duke
parents:
diff changeset
771 if( !r0->is_con() || !r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
772 return TypeLong::LONG; // Any integer, but still no symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
773
a61af66fc99e Initial load
duke
parents:
diff changeset
774 // Otherwise just OR them bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
775 return TypeLong::make( r0->get_con() | r1->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
776 }
a61af66fc99e Initial load
duke
parents:
diff changeset
777
a61af66fc99e Initial load
duke
parents:
diff changeset
778 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
779 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
780 // Supplied function returns the sum of the inputs IN THE CURRENT RING. For
a61af66fc99e Initial load
duke
parents:
diff changeset
781 // the logical operations the ring's ADD is really a logical OR function.
a61af66fc99e Initial load
duke
parents:
diff changeset
782 // This also type-checks the inputs for sanity. Guaranteed never to
a61af66fc99e Initial load
duke
parents:
diff changeset
783 // be passed a TOP or BOTTOM type, these are filtered out by pre-check.
a61af66fc99e Initial load
duke
parents:
diff changeset
784 const Type *XorINode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
785 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
786 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
787
a61af66fc99e Initial load
duke
parents:
diff changeset
788 // Complementing a boolean?
a61af66fc99e Initial load
duke
parents:
diff changeset
789 if( r0 == TypeInt::BOOL && ( r1 == TypeInt::ONE
a61af66fc99e Initial load
duke
parents:
diff changeset
790 || r1 == TypeInt::BOOL))
a61af66fc99e Initial load
duke
parents:
diff changeset
791 return TypeInt::BOOL;
a61af66fc99e Initial load
duke
parents:
diff changeset
792
a61af66fc99e Initial load
duke
parents:
diff changeset
793 if( !r0->is_con() || !r1->is_con() ) // Not constants
a61af66fc99e Initial load
duke
parents:
diff changeset
794 return TypeInt::INT; // Any integer, but still no symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
795
a61af66fc99e Initial load
duke
parents:
diff changeset
796 // Otherwise just XOR them bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
797 return TypeInt::make( r0->get_con() ^ r1->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
798 }
a61af66fc99e Initial load
duke
parents:
diff changeset
799
a61af66fc99e Initial load
duke
parents:
diff changeset
800 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
801 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
802 const Type *XorLNode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
803 const TypeLong *r0 = t0->is_long(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
804 const TypeLong *r1 = t1->is_long();
a61af66fc99e Initial load
duke
parents:
diff changeset
805
a61af66fc99e Initial load
duke
parents:
diff changeset
806 // If either input is not a constant, just return all integers.
a61af66fc99e Initial load
duke
parents:
diff changeset
807 if( !r0->is_con() || !r1->is_con() )
a61af66fc99e Initial load
duke
parents:
diff changeset
808 return TypeLong::LONG; // Any integer, but still no symbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
809
a61af66fc99e Initial load
duke
parents:
diff changeset
810 // Otherwise just OR them bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
811 return TypeLong::make( r0->get_con() ^ r1->get_con() );
a61af66fc99e Initial load
duke
parents:
diff changeset
812 }
a61af66fc99e Initial load
duke
parents:
diff changeset
813
a61af66fc99e Initial load
duke
parents:
diff changeset
814 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
815 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
816 // Supplied function returns the sum of the inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
817 const Type *MaxINode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
818 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
819 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
820
a61af66fc99e Initial load
duke
parents:
diff changeset
821 // Otherwise just MAX them bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
822 return TypeInt::make( MAX2(r0->_lo,r1->_lo), MAX2(r0->_hi,r1->_hi), MAX2(r0->_widen,r1->_widen) );
a61af66fc99e Initial load
duke
parents:
diff changeset
823 }
a61af66fc99e Initial load
duke
parents:
diff changeset
824
a61af66fc99e Initial load
duke
parents:
diff changeset
825 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
826 //------------------------------Idealize---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
827 // MINs show up in range-check loop limit calculations. Look for
a61af66fc99e Initial load
duke
parents:
diff changeset
828 // "MIN2(x+c0,MIN2(y,x+c1))". Pick the smaller constant: "MIN2(x+c0,y)"
a61af66fc99e Initial load
duke
parents:
diff changeset
829 Node *MinINode::Ideal(PhaseGVN *phase, bool can_reshape) {
a61af66fc99e Initial load
duke
parents:
diff changeset
830 Node *progress = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
831 // Force a right-spline graph
a61af66fc99e Initial load
duke
parents:
diff changeset
832 Node *l = in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
833 Node *r = in(2);
a61af66fc99e Initial load
duke
parents:
diff changeset
834 // Transform MinI1( MinI2(a,b), c) into MinI1( a, MinI2(b,c) )
a61af66fc99e Initial load
duke
parents:
diff changeset
835 // to force a right-spline graph for the rest of MinINode::Ideal().
a61af66fc99e Initial load
duke
parents:
diff changeset
836 if( l->Opcode() == Op_MinI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
837 assert( l != l->in(1), "dead loop in MinINode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
838 r = phase->transform(new (phase->C, 3) MinINode(l->in(2),r));
a61af66fc99e Initial load
duke
parents:
diff changeset
839 l = l->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
840 set_req(1, l);
a61af66fc99e Initial load
duke
parents:
diff changeset
841 set_req(2, r);
a61af66fc99e Initial load
duke
parents:
diff changeset
842 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
843 }
a61af66fc99e Initial load
duke
parents:
diff changeset
844
a61af66fc99e Initial load
duke
parents:
diff changeset
845 // Get left input & constant
a61af66fc99e Initial load
duke
parents:
diff changeset
846 Node *x = l;
a61af66fc99e Initial load
duke
parents:
diff changeset
847 int x_off = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
848 if( x->Opcode() == Op_AddI && // Check for "x+c0" and collect constant
a61af66fc99e Initial load
duke
parents:
diff changeset
849 x->in(2)->is_Con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
850 const Type *t = x->in(2)->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
851 if( t == Type::TOP ) return NULL; // No progress
a61af66fc99e Initial load
duke
parents:
diff changeset
852 x_off = t->is_int()->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
853 x = x->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
854 }
a61af66fc99e Initial load
duke
parents:
diff changeset
855
a61af66fc99e Initial load
duke
parents:
diff changeset
856 // Scan a right-spline-tree for MINs
a61af66fc99e Initial load
duke
parents:
diff changeset
857 Node *y = r;
a61af66fc99e Initial load
duke
parents:
diff changeset
858 int y_off = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
859 // Check final part of MIN tree
a61af66fc99e Initial load
duke
parents:
diff changeset
860 if( y->Opcode() == Op_AddI && // Check for "y+c1" and collect constant
a61af66fc99e Initial load
duke
parents:
diff changeset
861 y->in(2)->is_Con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
862 const Type *t = y->in(2)->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
863 if( t == Type::TOP ) return NULL; // No progress
a61af66fc99e Initial load
duke
parents:
diff changeset
864 y_off = t->is_int()->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
865 y = y->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
866 }
a61af66fc99e Initial load
duke
parents:
diff changeset
867 if( x->_idx > y->_idx && r->Opcode() != Op_MinI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
868 swap_edges(1, 2);
a61af66fc99e Initial load
duke
parents:
diff changeset
869 return this;
a61af66fc99e Initial load
duke
parents:
diff changeset
870 }
a61af66fc99e Initial load
duke
parents:
diff changeset
871
a61af66fc99e Initial load
duke
parents:
diff changeset
872
a61af66fc99e Initial load
duke
parents:
diff changeset
873 if( r->Opcode() == Op_MinI ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
874 assert( r != r->in(2), "dead loop in MinINode::Ideal" );
a61af66fc99e Initial load
duke
parents:
diff changeset
875 y = r->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
876 // Check final part of MIN tree
a61af66fc99e Initial load
duke
parents:
diff changeset
877 if( y->Opcode() == Op_AddI &&// Check for "y+c1" and collect constant
a61af66fc99e Initial load
duke
parents:
diff changeset
878 y->in(2)->is_Con() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
879 const Type *t = y->in(2)->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
880 if( t == Type::TOP ) return NULL; // No progress
a61af66fc99e Initial load
duke
parents:
diff changeset
881 y_off = t->is_int()->get_con();
a61af66fc99e Initial load
duke
parents:
diff changeset
882 y = y->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
883 }
a61af66fc99e Initial load
duke
parents:
diff changeset
884
a61af66fc99e Initial load
duke
parents:
diff changeset
885 if( x->_idx > y->_idx )
a61af66fc99e Initial load
duke
parents:
diff changeset
886 return new (phase->C, 3) MinINode(r->in(1),phase->transform(new (phase->C, 3) MinINode(l,r->in(2))));
a61af66fc99e Initial load
duke
parents:
diff changeset
887
a61af66fc99e Initial load
duke
parents:
diff changeset
888 // See if covers: MIN2(x+c0,MIN2(y+c1,z))
a61af66fc99e Initial load
duke
parents:
diff changeset
889 if( !phase->eqv(x,y) ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
890 // If (y == x) transform MIN2(x+c0, MIN2(x+c1,z)) into
a61af66fc99e Initial load
duke
parents:
diff changeset
891 // MIN2(x+c0 or x+c1 which less, z).
a61af66fc99e Initial load
duke
parents:
diff changeset
892 return new (phase->C, 3) MinINode(phase->transform(new (phase->C, 3) AddINode(x,phase->intcon(MIN2(x_off,y_off)))),r->in(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
893 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
894 // See if covers: MIN2(x+c0,y+c1)
a61af66fc99e Initial load
duke
parents:
diff changeset
895 if( !phase->eqv(x,y) ) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
896 // If (y == x) transform MIN2(x+c0,x+c1) into x+c0 or x+c1 which less.
a61af66fc99e Initial load
duke
parents:
diff changeset
897 return new (phase->C, 3) AddINode(x,phase->intcon(MIN2(x_off,y_off)));
a61af66fc99e Initial load
duke
parents:
diff changeset
898 }
a61af66fc99e Initial load
duke
parents:
diff changeset
899
a61af66fc99e Initial load
duke
parents:
diff changeset
900 }
a61af66fc99e Initial load
duke
parents:
diff changeset
901
a61af66fc99e Initial load
duke
parents:
diff changeset
902 //------------------------------add_ring---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
903 // Supplied function returns the sum of the inputs.
a61af66fc99e Initial load
duke
parents:
diff changeset
904 const Type *MinINode::add_ring( const Type *t0, const Type *t1 ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
905 const TypeInt *r0 = t0->is_int(); // Handy access
a61af66fc99e Initial load
duke
parents:
diff changeset
906 const TypeInt *r1 = t1->is_int();
a61af66fc99e Initial load
duke
parents:
diff changeset
907
a61af66fc99e Initial load
duke
parents:
diff changeset
908 // Otherwise just MIN them bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
909 return TypeInt::make( MIN2(r0->_lo,r1->_lo), MIN2(r0->_hi,r1->_hi), MAX2(r0->_widen,r1->_widen) );
a61af66fc99e Initial load
duke
parents:
diff changeset
910 }