src/share/vm/opto/addnode.cpp

Print this page




 303   // ( x == -5, z == 1, y ==  1 ) fails
 304   // Transform works for small z and small negative y when the addition
 305   // (x + (y << z)) does not cross zero.
 306   // Implement support for negative y and (x >= -(y << z))
 307   // Have not observed cases where type information exists to support
 308   // positive y and (x <= -(y << z))
 309   if( op1 == Op_URShiftI && op2 == Op_ConI &&
 310       in1->in(2)->Opcode() == Op_ConI ) {
 311     jint z = phase->type( in1->in(2) )->is_int()->get_con() & 0x1f; // only least significant 5 bits matter
 312     jint y = phase->type( in2 )->is_int()->get_con();
 313 
 314     if( z < 5 && -5 < y && y < 0 ) {
 315       const Type *t_in11 = phase->type(in1->in(1));
 316       if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) {
 317         Node *a = phase->transform( new (phase->C) AddINode( in1->in(1), phase->intcon(y<<z) ) );
 318         return new (phase->C) URShiftINode( a, in1->in(2) );
 319       }
 320     }
 321   }
 322 











































































 323   return AddNode::Ideal(phase, can_reshape);
 324 }
 325 
 326 
 327 //------------------------------Identity---------------------------------------
 328 // Fold (x-y)+y  OR  y+(x-y)  into  x
 329 Node *AddINode::Identity( PhaseTransform *phase ) {
 330   if( in(1)->Opcode() == Op_SubI && phase->eqv(in(1)->in(2),in(2)) ) {
 331     return in(1)->in(1);
 332   }
 333   else if( in(2)->Opcode() == Op_SubI && phase->eqv(in(2)->in(2),in(1)) ) {
 334     return in(2)->in(1);
 335   }
 336   return AddNode::Identity(phase);
 337 }
 338 
 339 
 340 //------------------------------add_ring---------------------------------------
 341 // Supplied function returns the sum of the inputs.  Guaranteed never
 342 // to be passed a TOP or BOTTOM type, these are filtered out by




 303   // ( x == -5, z == 1, y ==  1 ) fails
 304   // Transform works for small z and small negative y when the addition
 305   // (x + (y << z)) does not cross zero.
 306   // Implement support for negative y and (x >= -(y << z))
 307   // Have not observed cases where type information exists to support
 308   // positive y and (x <= -(y << z))
 309   if( op1 == Op_URShiftI && op2 == Op_ConI &&
 310       in1->in(2)->Opcode() == Op_ConI ) {
 311     jint z = phase->type( in1->in(2) )->is_int()->get_con() & 0x1f; // only least significant 5 bits matter
 312     jint y = phase->type( in2 )->is_int()->get_con();
 313 
 314     if( z < 5 && -5 < y && y < 0 ) {
 315       const Type *t_in11 = phase->type(in1->in(1));
 316       if( t_in11 != Type::TOP && (t_in11->is_int()->_lo >= -(y << z)) ) {
 317         Node *a = phase->transform( new (phase->C) AddINode( in1->in(1), phase->intcon(y<<z) ) );
 318         return new (phase->C) URShiftINode( a, in1->in(2) );
 319       }
 320     }
 321   }
 322 
 323 // Converts the following tree to a loadI if loaded 4 bytes are contiguous.
 324 //
 325 //                                                 this:AddI
 326 //                                                      |
 327 //                                 in1:AddI-------------+------------in2:LShiftI
 328 //                                     |                                    |
 329 //                in3:AddI-------------+------------in4:LShiftI  in5:LoadB--+--...
 330 //                    |                                    |        |
 331 //       in6:AndI-----+-----in7:LShiftI          in8:AndI--+--...  mem
 332 //            |                    |                   |
 333 // in9:loadB--+--...    in10:AndI--+--...  in11:LoadB--+--... 
 334 //     |                    |                  |
 335 //    mem              in12:LoadB             mem
 336 //                          | 
 337 //                         mem
 338 //
 339   if ( op1 == Op_AddI && op2 == Op_LShiftI ) {
 340     Node *in3 = in1->in(1);
 341     Node *in4 = in1->in(2);
 342     Node *in5 = in2->in(1);
 343     if ( in3->Opcode() == Op_AddI && 
 344          in4->Opcode() == Op_LShiftI && 
 345          in5->Opcode() == Op_LoadB ) {
 346       Node *in6 = in3->in(1);
 347       Node *in7 = in3->in(2);
 348       Node *in8 = in4->in(1);
 349       if ( in6->Opcode() == Op_AndI &&
 350            in7->Opcode() == Op_LShiftI && 
 351            in8->Opcode() == Op_AndI ) {
 352         Node *in9 = in6->in(1);
 353         Node *in10 = in7->in(1);
 354         Node *in11 = in8->in(1);
 355         if ( in9->Opcode() == Op_LoadB && 
 356              in10->Opcode() == Op_AndI && 
 357              in11->Opcode() == Op_LoadB ) {
 358          Node *in12 = in10->in(1);
 359          if ( in12->Opcode() == Op_LoadB ) {
 360             LoadBNode *loadb1 = (LoadBNode *) in9;
 361             Node *adr1 = loadb1->in(MemNode::Address);
 362             Node *load1_base = adr1->in(1);
 363             const TypePtr* tp1 = adr1->bottom_type()->isa_ptr();
 364             int load1_offset = tp1->offset();
 365 
 366             LoadBNode *loadb2 = (LoadBNode *) in12;
 367             Node *adr2 = loadb2->in(MemNode::Address);
 368             Node *load2_base = adr2->in(1);
 369             const TypePtr* tp2 = adr2->bottom_type()->isa_ptr();
 370             int load2_offset = tp2->offset();
 371 
 372             LoadBNode *loadb3 = (LoadBNode *) in11;
 373             Node *adr3 = loadb3->in(MemNode::Address);
 374             Node *load3_base = adr3->in(1);
 375             const TypePtr* tp3 = adr3->bottom_type()->isa_ptr();
 376             int load3_offset = tp3->offset();
 377 
 378             LoadBNode *loadb4 = (LoadBNode *) in5;
 379             Node *adr4 = loadb4->in(MemNode::Address);
 380             Node *load4_base = adr4->in(1);
 381             const TypePtr* tp4 = adr4->bottom_type()->isa_ptr();
 382             int load4_offset = tp4->offset();
 383 
 384             if ( load1_base == load2_base &&
 385                  load1_base == load3_base &&
 386                  load1_base == load4_base &&
 387                  load1_offset + 1 == load2_offset &&
 388                  load2_offset + 1 == load3_offset &&
 389                  load3_offset + 1 == load4_offset ) {
 390               return new (phase->C) LoadINode(NULL, load1_base, adr1, tp1, TypeInt::INT, MemNode::unordered);
 391             }
 392           }
 393         }
 394       }
 395     }
 396   }
 397 
 398   return AddNode::Ideal(phase, can_reshape);
 399 }
 400 
 401 
 402 //------------------------------Identity---------------------------------------
 403 // Fold (x-y)+y  OR  y+(x-y)  into  x
 404 Node *AddINode::Identity( PhaseTransform *phase ) {
 405   if( in(1)->Opcode() == Op_SubI && phase->eqv(in(1)->in(2),in(2)) ) {
 406     return in(1)->in(1);
 407   }
 408   else if( in(2)->Opcode() == Op_SubI && phase->eqv(in(2)->in(2),in(1)) ) {
 409     return in(2)->in(1);
 410   }
 411   return AddNode::Identity(phase);
 412 }
 413 
 414 
 415 //------------------------------add_ring---------------------------------------
 416 // Supplied function returns the sum of the inputs.  Guaranteed never
 417 // to be passed a TOP or BOTTOM type, these are filtered out by