comparison src/share/vm/opto/addnode.cpp @ 6804:e626685e9f6c

7193318: C2: remove number of inputs requirement from Node's new operator Summary: Deleted placement new operator of Node - node(size_t, Compile *, int). Reviewed-by: kvn, twisti Contributed-by: bharadwaj.yadavalli@oracle.com
author kvn
date Thu, 27 Sep 2012 09:38:42 -0700
parents a6eef545f1a2
children b9a9ed0f8eeb
comparison
equal deleted inserted replaced
6803:06f52c4d0e18 6804:e626685e9f6c
246 } 246 }
247 if( op1 == Op_SubI ) { 247 if( op1 == Op_SubI ) {
248 const Type *t_sub1 = phase->type( in1->in(1) ); 248 const Type *t_sub1 = phase->type( in1->in(1) );
249 const Type *t_2 = phase->type( in2 ); 249 const Type *t_2 = phase->type( in2 );
250 if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP ) 250 if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP )
251 return new (phase->C, 3) SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ), 251 return new (phase->C) SubINode(phase->makecon( add_ring( t_sub1, t_2 ) ),
252 in1->in(2) ); 252 in1->in(2) );
253 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)" 253 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)"
254 if( op2 == Op_SubI ) { 254 if( op2 == Op_SubI ) {
255 // Check for dead cycle: d = (a-b)+(c-d) 255 // Check for dead cycle: d = (a-b)+(c-d)
256 assert( in1->in(2) != this && in2->in(2) != this, 256 assert( in1->in(2) != this && in2->in(2) != this,
257 "dead loop in AddINode::Ideal" ); 257 "dead loop in AddINode::Ideal" );
258 Node *sub = new (phase->C, 3) SubINode(NULL, NULL); 258 Node *sub = new (phase->C) SubINode(NULL, NULL);
259 sub->init_req(1, phase->transform(new (phase->C, 3) AddINode(in1->in(1), in2->in(1) ) )); 259 sub->init_req(1, phase->transform(new (phase->C) AddINode(in1->in(1), in2->in(1) ) ));
260 sub->init_req(2, phase->transform(new (phase->C, 3) AddINode(in1->in(2), in2->in(2) ) )); 260 sub->init_req(2, phase->transform(new (phase->C) AddINode(in1->in(2), in2->in(2) ) ));
261 return sub; 261 return sub;
262 } 262 }
263 // Convert "(a-b)+(b+c)" into "(a+c)" 263 // Convert "(a-b)+(b+c)" into "(a+c)"
264 if( op2 == Op_AddI && in1->in(2) == in2->in(1) ) { 264 if( op2 == Op_AddI && in1->in(2) == in2->in(1) ) {
265 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal"); 265 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal");
266 return new (phase->C, 3) AddINode(in1->in(1), in2->in(2)); 266 return new (phase->C) AddINode(in1->in(1), in2->in(2));
267 } 267 }
268 // Convert "(a-b)+(c+b)" into "(a+c)" 268 // Convert "(a-b)+(c+b)" into "(a+c)"
269 if( op2 == Op_AddI && in1->in(2) == in2->in(2) ) { 269 if( op2 == Op_AddI && in1->in(2) == in2->in(2) ) {
270 assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddINode::Ideal"); 270 assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddINode::Ideal");
271 return new (phase->C, 3) AddINode(in1->in(1), in2->in(1)); 271 return new (phase->C) AddINode(in1->in(1), in2->in(1));
272 } 272 }
273 // Convert "(a-b)+(b-c)" into "(a-c)" 273 // Convert "(a-b)+(b-c)" into "(a-c)"
274 if( op2 == Op_SubI && in1->in(2) == in2->in(1) ) { 274 if( op2 == Op_SubI && in1->in(2) == in2->in(1) ) {
275 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal"); 275 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddINode::Ideal");
276 return new (phase->C, 3) SubINode(in1->in(1), in2->in(2)); 276 return new (phase->C) SubINode(in1->in(1), in2->in(2));
277 } 277 }
278 // Convert "(a-b)+(c-a)" into "(c-b)" 278 // Convert "(a-b)+(c-a)" into "(c-b)"
279 if( op2 == Op_SubI && in1->in(1) == in2->in(2) ) { 279 if( op2 == Op_SubI && in1->in(1) == in2->in(2) ) {
280 assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddINode::Ideal"); 280 assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddINode::Ideal");
281 return new (phase->C, 3) SubINode(in2->in(1), in1->in(2)); 281 return new (phase->C) SubINode(in2->in(1), in1->in(2));
282 } 282 }
283 } 283 }
284 284
285 // Convert "x+(0-y)" into "(x-y)" 285 // Convert "x+(0-y)" into "(x-y)"
286 if( op2 == Op_SubI && phase->type(in2->in(1)) == TypeInt::ZERO ) 286 if( op2 == Op_SubI && phase->type(in2->in(1)) == TypeInt::ZERO )
287 return new (phase->C, 3) SubINode(in1, in2->in(2) ); 287 return new (phase->C) SubINode(in1, in2->in(2) );
288 288
289 // Convert "(0-y)+x" into "(x-y)" 289 // Convert "(0-y)+x" into "(x-y)"
290 if( op1 == Op_SubI && phase->type(in1->in(1)) == TypeInt::ZERO ) 290 if( op1 == Op_SubI && phase->type(in1->in(1)) == TypeInt::ZERO )
291 return new (phase->C, 3) SubINode( in2, in1->in(2) ); 291 return new (phase->C) SubINode( in2, in1->in(2) );
292 292
293 // Convert (x>>>z)+y into (x+(y<<z))>>>z for small constant z and y. 293 // Convert (x>>>z)+y into (x+(y<<z))>>>z for small constant z and y.
294 // Helps with array allocation math constant folding 294 // Helps with array allocation math constant folding
295 // See 4790063: 295 // See 4790063:
296 // Unrestricted transformation is unsafe for some runtime values of 'x' 296 // Unrestricted transformation is unsafe for some runtime values of 'x'
307 jint y = phase->type( in2 )->is_int()->get_con(); 307 jint y = phase->type( in2 )->is_int()->get_con();
308 308
309 if( z < 5 && -5 < y && y < 0 ) { 309 if( z < 5 && -5 < y && y < 0 ) {
310 const Type *t_in11 = phase->type(in1->in(1)); 310 const Type *t_in11 = phase->type(in1->in(1));
311 if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) { 311 if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) {
312 Node *a = phase->transform( new (phase->C, 3) AddINode( in1->in(1), phase->intcon(y<<z) ) ); 312 Node *a = phase->transform( new (phase->C) AddINode( in1->in(1), phase->intcon(y<<z) ) );
313 return new (phase->C, 3) URShiftINode( a, in1->in(2) ); 313 return new (phase->C) URShiftINode( a, in1->in(2) );
314 } 314 }
315 } 315 }
316 } 316 }
317 317
318 return AddNode::Ideal(phase, can_reshape); 318 return AddNode::Ideal(phase, can_reshape);
379 // Fold (con1-x)+con2 into (con1+con2)-x 379 // Fold (con1-x)+con2 into (con1+con2)-x
380 if( op1 == Op_SubL ) { 380 if( op1 == Op_SubL ) {
381 const Type *t_sub1 = phase->type( in1->in(1) ); 381 const Type *t_sub1 = phase->type( in1->in(1) );
382 const Type *t_2 = phase->type( in2 ); 382 const Type *t_2 = phase->type( in2 );
383 if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP ) 383 if( t_sub1->singleton() && t_2->singleton() && t_sub1 != Type::TOP && t_2 != Type::TOP )
384 return new (phase->C, 3) SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ), 384 return new (phase->C) SubLNode(phase->makecon( add_ring( t_sub1, t_2 ) ),
385 in1->in(2) ); 385 in1->in(2) );
386 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)" 386 // Convert "(a-b)+(c-d)" into "(a+c)-(b+d)"
387 if( op2 == Op_SubL ) { 387 if( op2 == Op_SubL ) {
388 // Check for dead cycle: d = (a-b)+(c-d) 388 // Check for dead cycle: d = (a-b)+(c-d)
389 assert( in1->in(2) != this && in2->in(2) != this, 389 assert( in1->in(2) != this && in2->in(2) != this,
390 "dead loop in AddLNode::Ideal" ); 390 "dead loop in AddLNode::Ideal" );
391 Node *sub = new (phase->C, 3) SubLNode(NULL, NULL); 391 Node *sub = new (phase->C) SubLNode(NULL, NULL);
392 sub->init_req(1, phase->transform(new (phase->C, 3) AddLNode(in1->in(1), in2->in(1) ) )); 392 sub->init_req(1, phase->transform(new (phase->C) AddLNode(in1->in(1), in2->in(1) ) ));
393 sub->init_req(2, phase->transform(new (phase->C, 3) AddLNode(in1->in(2), in2->in(2) ) )); 393 sub->init_req(2, phase->transform(new (phase->C) AddLNode(in1->in(2), in2->in(2) ) ));
394 return sub; 394 return sub;
395 } 395 }
396 // Convert "(a-b)+(b+c)" into "(a+c)" 396 // Convert "(a-b)+(b+c)" into "(a+c)"
397 if( op2 == Op_AddL && in1->in(2) == in2->in(1) ) { 397 if( op2 == Op_AddL && in1->in(2) == in2->in(1) ) {
398 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal"); 398 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal");
399 return new (phase->C, 3) AddLNode(in1->in(1), in2->in(2)); 399 return new (phase->C) AddLNode(in1->in(1), in2->in(2));
400 } 400 }
401 // Convert "(a-b)+(c+b)" into "(a+c)" 401 // Convert "(a-b)+(c+b)" into "(a+c)"
402 if( op2 == Op_AddL && in1->in(2) == in2->in(2) ) { 402 if( op2 == Op_AddL && in1->in(2) == in2->in(2) ) {
403 assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal"); 403 assert(in1->in(1) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal");
404 return new (phase->C, 3) AddLNode(in1->in(1), in2->in(1)); 404 return new (phase->C) AddLNode(in1->in(1), in2->in(1));
405 } 405 }
406 // Convert "(a-b)+(b-c)" into "(a-c)" 406 // Convert "(a-b)+(b-c)" into "(a-c)"
407 if( op2 == Op_SubL && in1->in(2) == in2->in(1) ) { 407 if( op2 == Op_SubL && in1->in(2) == in2->in(1) ) {
408 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal"); 408 assert(in1->in(1) != this && in2->in(2) != this,"dead loop in AddLNode::Ideal");
409 return new (phase->C, 3) SubLNode(in1->in(1), in2->in(2)); 409 return new (phase->C) SubLNode(in1->in(1), in2->in(2));
410 } 410 }
411 // Convert "(a-b)+(c-a)" into "(c-b)" 411 // Convert "(a-b)+(c-a)" into "(c-b)"
412 if( op2 == Op_SubL && in1->in(1) == in1->in(2) ) { 412 if( op2 == Op_SubL && in1->in(1) == in1->in(2) ) {
413 assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal"); 413 assert(in1->in(2) != this && in2->in(1) != this,"dead loop in AddLNode::Ideal");
414 return new (phase->C, 3) SubLNode(in2->in(1), in1->in(2)); 414 return new (phase->C) SubLNode(in2->in(1), in1->in(2));
415 } 415 }
416 } 416 }
417 417
418 // Convert "x+(0-y)" into "(x-y)" 418 // Convert "x+(0-y)" into "(x-y)"
419 if( op2 == Op_SubL && phase->type(in2->in(1)) == TypeLong::ZERO ) 419 if( op2 == Op_SubL && phase->type(in2->in(1)) == TypeLong::ZERO )
420 return new (phase->C, 3) SubLNode( in1, in2->in(2) ); 420 return new (phase->C) SubLNode( in1, in2->in(2) );
421 421
422 // Convert "(0-y)+x" into "(x-y)" 422 // Convert "(0-y)+x" into "(x-y)"
423 if( op1 == Op_SubL && phase->type(in1->in(1)) == TypeInt::ZERO ) 423 if( op1 == Op_SubL && phase->type(in1->in(1)) == TypeInt::ZERO )
424 return new (phase->C, 3) SubLNode( in2, in1->in(2) ); 424 return new (phase->C) SubLNode( in2, in1->in(2) );
425 425
426 // Convert "X+X+X+X+X...+X+Y" into "k*X+Y" or really convert "X+(X+Y)" 426 // Convert "X+X+X+X+X...+X+Y" into "k*X+Y" or really convert "X+(X+Y)"
427 // into "(X<<1)+Y" and let shift-folding happen. 427 // into "(X<<1)+Y" and let shift-folding happen.
428 if( op2 == Op_AddL && 428 if( op2 == Op_AddL &&
429 in2->in(1) == in1 && 429 in2->in(1) == in1 &&
430 op1 != Op_ConL && 430 op1 != Op_ConL &&
431 0 ) { 431 0 ) {
432 Node *shift = phase->transform(new (phase->C, 3) LShiftLNode(in1,phase->intcon(1))); 432 Node *shift = phase->transform(new (phase->C) LShiftLNode(in1,phase->intcon(1)));
433 return new (phase->C, 3) AddLNode(shift,in2->in(2)); 433 return new (phase->C) AddLNode(shift,in2->in(2));
434 } 434 }
435 435
436 return AddNode::Ideal(phase, can_reshape); 436 return AddNode::Ideal(phase, can_reshape);
437 } 437 }
438 438
588 // The Add of the flattened expression 588 // The Add of the flattened expression
589 address = addp->in(Address); 589 address = addp->in(Address);
590 offset = phase->MakeConX(t2->get_con() + t12->get_con()); 590 offset = phase->MakeConX(t2->get_con() + t12->get_con());
591 } else { 591 } else {
592 // Else move the constant to the right. ((A+con)+B) into ((A+B)+con) 592 // Else move the constant to the right. ((A+con)+B) into ((A+B)+con)
593 address = phase->transform(new (phase->C, 4) AddPNode(in(Base),addp->in(Address),in(Offset))); 593 address = phase->transform(new (phase->C) AddPNode(in(Base),addp->in(Address),in(Offset)));
594 offset = addp->in(Offset); 594 offset = addp->in(Offset);
595 } 595 }
596 PhaseIterGVN *igvn = phase->is_IterGVN(); 596 PhaseIterGVN *igvn = phase->is_IterGVN();
597 if( igvn ) { 597 if( igvn ) {
598 set_req_X(Address,address,igvn); 598 set_req_X(Address,address,igvn);
608 // Raw pointers? 608 // Raw pointers?
609 if( in(Base)->bottom_type() == Type::TOP ) { 609 if( in(Base)->bottom_type() == Type::TOP ) {
610 // If this is a NULL+long form (from unsafe accesses), switch to a rawptr. 610 // If this is a NULL+long form (from unsafe accesses), switch to a rawptr.
611 if (phase->type(in(Address)) == TypePtr::NULL_PTR) { 611 if (phase->type(in(Address)) == TypePtr::NULL_PTR) {
612 Node* offset = in(Offset); 612 Node* offset = in(Offset);
613 return new (phase->C, 2) CastX2PNode(offset); 613 return new (phase->C) CastX2PNode(offset);
614 } 614 }
615 } 615 }
616 616
617 // If the right is an add of a constant, push the offset down. 617 // If the right is an add of a constant, push the offset down.
618 // Convert: (ptr + (offset+con)) into (ptr+offset)+con. 618 // Convert: (ptr + (offset+con)) into (ptr+offset)+con.
620 // and only have different constant offsets from the same base. 620 // and only have different constant offsets from the same base.
621 const Node *add = in(Offset); 621 const Node *add = in(Offset);
622 if( add->Opcode() == Op_AddX && add->in(1) != add ) { 622 if( add->Opcode() == Op_AddX && add->in(1) != add ) {
623 const Type *t22 = phase->type( add->in(2) ); 623 const Type *t22 = phase->type( add->in(2) );
624 if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant? 624 if( t22->singleton() && (t22 != Type::TOP) ) { // Right input is an add of a constant?
625 set_req(Address, phase->transform(new (phase->C, 4) AddPNode(in(Base),in(Address),add->in(1)))); 625 set_req(Address, phase->transform(new (phase->C) AddPNode(in(Base),in(Address),add->in(1))));
626 set_req(Offset, add->in(2)); 626 set_req(Offset, add->in(2));
627 return this; // Made progress 627 return this; // Made progress
628 } 628 }
629 } 629 }
630 630
845 Node *r = in(2); 845 Node *r = in(2);
846 // Transform MinI1( MinI2(a,b), c) into MinI1( a, MinI2(b,c) ) 846 // Transform MinI1( MinI2(a,b), c) into MinI1( a, MinI2(b,c) )
847 // to force a right-spline graph for the rest of MinINode::Ideal(). 847 // to force a right-spline graph for the rest of MinINode::Ideal().
848 if( l->Opcode() == Op_MinI ) { 848 if( l->Opcode() == Op_MinI ) {
849 assert( l != l->in(1), "dead loop in MinINode::Ideal" ); 849 assert( l != l->in(1), "dead loop in MinINode::Ideal" );
850 r = phase->transform(new (phase->C, 3) MinINode(l->in(2),r)); 850 r = phase->transform(new (phase->C) MinINode(l->in(2),r));
851 l = l->in(1); 851 l = l->in(1);
852 set_req(1, l); 852 set_req(1, l);
853 set_req(2, r); 853 set_req(2, r);
854 return this; 854 return this;
855 } 855 }
893 y_off = t->is_int()->get_con(); 893 y_off = t->is_int()->get_con();
894 y = y->in(1); 894 y = y->in(1);
895 } 895 }
896 896
897 if( x->_idx > y->_idx ) 897 if( x->_idx > y->_idx )
898 return new (phase->C, 3) MinINode(r->in(1),phase->transform(new (phase->C, 3) MinINode(l,r->in(2)))); 898 return new (phase->C) MinINode(r->in(1),phase->transform(new (phase->C) MinINode(l,r->in(2))));
899 899
900 // See if covers: MIN2(x+c0,MIN2(y+c1,z)) 900 // See if covers: MIN2(x+c0,MIN2(y+c1,z))
901 if( !phase->eqv(x,y) ) return NULL; 901 if( !phase->eqv(x,y) ) return NULL;
902 // If (y == x) transform MIN2(x+c0, MIN2(x+c1,z)) into 902 // If (y == x) transform MIN2(x+c0, MIN2(x+c1,z)) into
903 // MIN2(x+c0 or x+c1 which less, z). 903 // MIN2(x+c0 or x+c1 which less, z).
904 return new (phase->C, 3) MinINode(phase->transform(new (phase->C, 3) AddINode(x,phase->intcon(MIN2(x_off,y_off)))),r->in(2)); 904 return new (phase->C) MinINode(phase->transform(new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off)))),r->in(2));
905 } else { 905 } else {
906 // See if covers: MIN2(x+c0,y+c1) 906 // See if covers: MIN2(x+c0,y+c1)
907 if( !phase->eqv(x,y) ) return NULL; 907 if( !phase->eqv(x,y) ) return NULL;
908 // If (y == x) transform MIN2(x+c0,x+c1) into x+c0 or x+c1 which less. 908 // If (y == x) transform MIN2(x+c0,x+c1) into x+c0 or x+c1 which less.
909 return new (phase->C, 3) AddINode(x,phase->intcon(MIN2(x_off,y_off))); 909 return new (phase->C) AddINode(x,phase->intcon(MIN2(x_off,y_off)));
910 } 910 }
911 911
912 } 912 }
913 913
914 //------------------------------add_ring--------------------------------------- 914 //------------------------------add_ring---------------------------------------