src/share/vm/opto/subnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6667595 Sdiff src/share/vm/opto

src/share/vm/opto/subnode.cpp

Print this page




 189     return new (phase->C, 3) SubINode( phase->intcon(0),in2->in(1));
 190 
 191   // Convert "0 - (x-y)" into "y-x"
 192   if( t1 == TypeInt::ZERO && op2 == Op_SubI )
 193     return new (phase->C, 3) SubINode( in2->in(2), in2->in(1) );
 194 
 195   // Convert "0 - (x+con)" into "-con-x"
 196   jint con;
 197   if( t1 == TypeInt::ZERO && op2 == Op_AddI &&
 198       (con = in2->in(2)->find_int_con(0)) != 0 )
 199     return new (phase->C, 3) SubINode( phase->intcon(-con), in2->in(1) );
 200 
 201   // Convert "(X+A) - (X+B)" into "A - B"
 202   if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(1) )
 203     return new (phase->C, 3) SubINode( in1->in(2), in2->in(2) );
 204 
 205   // Convert "(A+X) - (B+X)" into "A - B"
 206   if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) )
 207     return new (phase->C, 3) SubINode( in1->in(1), in2->in(1) );
 208 








 209   // Convert "A-(B-C)" into (A+C)-B", since add is commutative and generally
 210   // nicer to optimize than subtract.
 211   if( op2 == Op_SubI && in2->outcnt() == 1) {
 212     Node *add1 = phase->transform( new (phase->C, 3) AddINode( in1, in2->in(2) ) );
 213     return new (phase->C, 3) SubINode( add1, in2->in(1) );
 214   }
 215 
 216   return NULL;
 217 }
 218 
 219 //------------------------------sub--------------------------------------------
 220 // A subtract node differences it's two inputs.
 221 const Type *SubINode::sub( const Type *t1, const Type *t2 ) const {
 222   const TypeInt *r0 = t1->is_int(); // Handy access
 223   const TypeInt *r1 = t2->is_int();
 224   int32 lo = r0->_lo - r1->_hi;
 225   int32 hi = r0->_hi - r1->_lo;
 226 
 227   // We next check for 32-bit overflow.
 228   // If that happens, we just assume all integers are possible.




 189     return new (phase->C, 3) SubINode( phase->intcon(0),in2->in(1));
 190 
 191   // Convert "0 - (x-y)" into "y-x"
 192   if( t1 == TypeInt::ZERO && op2 == Op_SubI )
 193     return new (phase->C, 3) SubINode( in2->in(2), in2->in(1) );
 194 
 195   // Convert "0 - (x+con)" into "-con-x"
 196   jint con;
 197   if( t1 == TypeInt::ZERO && op2 == Op_AddI &&
 198       (con = in2->in(2)->find_int_con(0)) != 0 )
 199     return new (phase->C, 3) SubINode( phase->intcon(-con), in2->in(1) );
 200 
 201   // Convert "(X+A) - (X+B)" into "A - B"
 202   if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(1) )
 203     return new (phase->C, 3) SubINode( in1->in(2), in2->in(2) );
 204 
 205   // Convert "(A+X) - (B+X)" into "A - B"
 206   if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) )
 207     return new (phase->C, 3) SubINode( in1->in(1), in2->in(1) );
 208 
 209   // Convert "(A+X) - (X+B)" into "A - B"
 210   if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(1) )
 211     return new (phase->C, 3) SubINode( in1->in(1), in2->in(2) );
 212 
 213   // Convert "(X+A) - (B+X)" into "A - B"
 214   if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(2) )
 215     return new (phase->C, 3) SubINode( in1->in(2), in2->in(1) );
 216 
 217   // Convert "A-(B-C)" into (A+C)-B", since add is commutative and generally
 218   // nicer to optimize than subtract.
 219   if( op2 == Op_SubI && in2->outcnt() == 1) {
 220     Node *add1 = phase->transform( new (phase->C, 3) AddINode( in1, in2->in(2) ) );
 221     return new (phase->C, 3) SubINode( add1, in2->in(1) );
 222   }
 223 
 224   return NULL;
 225 }
 226 
 227 //------------------------------sub--------------------------------------------
 228 // A subtract node differences it's two inputs.
 229 const Type *SubINode::sub( const Type *t1, const Type *t2 ) const {
 230   const TypeInt *r0 = t1->is_int(); // Handy access
 231   const TypeInt *r1 = t2->is_int();
 232   int32 lo = r0->_lo - r1->_hi;
 233   int32 hi = r0->_hi - r1->_lo;
 234 
 235   // We next check for 32-bit overflow.
 236   // If that happens, we just assume all integers are possible.


src/share/vm/opto/subnode.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File