annotate src/share/vm/opto/addnode.cpp @ 196:d1605aabd0a1

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