src/share/vm/opto/subnode.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/share/vm/opto/subnode.cpp Thu May 15 17:09:32 2014
--- new/src/share/vm/opto/subnode.cpp Thu May 15 17:09:32 2014
*** 147,167 ****
--- 147,167 ----
if( t2 == Type::TOP ) return NULL;
// Convert "x-c0" into "x+ -c0".
if( t2->base() == Type::Int ){ // Might be bottom or top...
const TypeInt *i = t2->is_int();
if( i->is_con() )
- return new (phase->C) AddINode(in1, phase->intcon(-i->get_con()));
}
// Convert "(x+c0) - y" into (x-y) + c0"
// Do not collapse (x+c0)-y if "+" is a loop increment or
// if "y" is a loop induction variable.
if( op1 == Op_AddI && ok_to_convert(in1, in2) ) {
const Type *tadd = phase->type( in1->in(2) );
if( tadd->singleton() && tadd != Type::TOP ) {
- Node *sub2 = phase->transform( new (phase->C) SubINode( in1->in(1), in2 ));
- return new (phase->C) AddINode( sub2, in1->in(2) );
}
}
// Convert "x - (y+c0)" into "(x-y) - c0"
*** 169,181 ****
--- 169,181 ----
if (op2 == Op_AddI && ok_to_convert(in2, in1)) {
Node* in21 = in2->in(1);
Node* in22 = in2->in(2);
const TypeInt* tcon = phase->type(in22)->isa_int();
if (tcon != NULL && tcon->is_con()) {
- Node* sub2 = phase->transform( new (phase->C) SubINode(in1, in21) );
Node* neg_c0 = phase->intcon(- tcon->get_con());
- return new (phase->C) AddINode(sub2, neg_c0);
}
}
const Type *t1 = phase->type( in1 );
if( t1 == Type::TOP ) return NULL;
*** 189,239 ****
--- 189,239 ----
#endif
// Convert "x - (x+y)" into "-y"
if( op2 == Op_AddI &&
phase->eqv( in1, in2->in(1) ) )
- return new (phase->C) SubINode( phase->intcon(0),in2->in(2));
// Convert "(x-y) - x" into "-y"
if( op1 == Op_SubI &&
phase->eqv( in1->in(1), in2 ) )
- return new (phase->C) SubINode( phase->intcon(0),in1->in(2));
// Convert "x - (y+x)" into "-y"
if( op2 == Op_AddI &&
phase->eqv( in1, in2->in(2) ) )
- return new (phase->C) SubINode( phase->intcon(0),in2->in(1));
// Convert "0 - (x-y)" into "y-x"
if( t1 == TypeInt::ZERO && op2 == Op_SubI )
- return new (phase->C) SubINode( in2->in(2), in2->in(1) );
// Convert "0 - (x+con)" into "-con-x"
jint con;
if( t1 == TypeInt::ZERO && op2 == Op_AddI &&
(con = in2->in(2)->find_int_con(0)) != 0 )
- return new (phase->C) SubINode( phase->intcon(-con), in2->in(1) );
// Convert "(X+A) - (X+B)" into "A - B"
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(1) )
- return new (phase->C) SubINode( in1->in(2), in2->in(2) );
// Convert "(A+X) - (B+X)" into "A - B"
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) )
- return new (phase->C) SubINode( in1->in(1), in2->in(1) );
// Convert "(A+X) - (X+B)" into "A - B"
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(1) )
- return new (phase->C) SubINode( in1->in(1), in2->in(2) );
// Convert "(X+A) - (B+X)" into "A - B"
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(1) == in2->in(2) )
- return new (phase->C) SubINode( in1->in(2), in2->in(1) );
// Convert "A-(B-C)" into (A+C)-B", since add is commutative and generally
// nicer to optimize than subtract.
if( op2 == Op_SubI && in2->outcnt() == 1) {
- Node *add1 = phase->transform( new (phase->C) AddINode( in1, in2->in(2) ) );
- return new (phase->C) SubINode( add1, in2->in(1) );
}
return NULL;
}
*** 276,309 ****
--- 276,309 ----
if( phase->type( in2 ) == Type::TOP ) return NULL;
const TypeLong *i = phase->type( in2 )->isa_long();
// Convert "x-c0" into "x+ -c0".
if( i && // Might be bottom or top...
i->is_con() )
- return new (phase->C) AddLNode(in1, phase->longcon(-i->get_con()));
// Convert "(x+c0) - y" into (x-y) + c0"
// Do not collapse (x+c0)-y if "+" is a loop increment or
// if "y" is a loop induction variable.
if( op1 == Op_AddL && ok_to_convert(in1, in2) ) {
Node *in11 = in1->in(1);
const Type *tadd = phase->type( in1->in(2) );
if( tadd->singleton() && tadd != Type::TOP ) {
- Node *sub2 = phase->transform( new (phase->C) SubLNode( in11, in2 ));
- return new (phase->C) AddLNode( sub2, in1->in(2) );
}
}
// Convert "x - (y+c0)" into "(x-y) - c0"
// Need the same check as in above optimization but reversed.
if (op2 == Op_AddL && ok_to_convert(in2, in1)) {
Node* in21 = in2->in(1);
Node* in22 = in2->in(2);
const TypeLong* tcon = phase->type(in22)->isa_long();
if (tcon != NULL && tcon->is_con()) {
- Node* sub2 = phase->transform( new (phase->C) SubLNode(in1, in21) );
Node* neg_c0 = phase->longcon(- tcon->get_con());
- return new (phase->C) AddLNode(sub2, neg_c0);
}
}
const Type *t1 = phase->type( in1 );
if( t1 == Type::TOP ) return NULL;
*** 317,348 ****
--- 317,348 ----
#endif
// Convert "x - (x+y)" into "-y"
if( op2 == Op_AddL &&
phase->eqv( in1, in2->in(1) ) )
- return new (phase->C) SubLNode( phase->makecon(TypeLong::ZERO), in2->in(2));
// Convert "x - (y+x)" into "-y"
if( op2 == Op_AddL &&
phase->eqv( in1, in2->in(2) ) )
- return new (phase->C) SubLNode( phase->makecon(TypeLong::ZERO),in2->in(1));
// Convert "0 - (x-y)" into "y-x"
if( phase->type( in1 ) == TypeLong::ZERO && op2 == Op_SubL )
- return new (phase->C) SubLNode( in2->in(2), in2->in(1) );
// Convert "(X+A) - (X+B)" into "A - B"
if( op1 == Op_AddL && op2 == Op_AddL && in1->in(1) == in2->in(1) )
- return new (phase->C) SubLNode( in1->in(2), in2->in(2) );
// Convert "(A+X) - (B+X)" into "A - B"
if( op1 == Op_AddL && op2 == Op_AddL && in1->in(2) == in2->in(2) )
- return new (phase->C) SubLNode( in1->in(1), in2->in(1) );
// Convert "A-(B-C)" into (A+C)-B"
if( op2 == Op_SubL && in2->outcnt() == 1) {
- Node *add1 = phase->transform( new (phase->C) AddLNode( in1, in2->in(2) ) );
- return new (phase->C) SubLNode( add1, in2->in(1) );
}
return NULL;
}
*** 405,415 ****
--- 405,415 ----
// Not associative because of boundary conditions (infinity)
if( IdealizedNumerics && !phase->C->method()->is_strict() ) {
// Convert "x - (x+y)" into "-y"
if( in(2)->is_Add() &&
phase->eqv(in(1),in(2)->in(1) ) )
- return new (phase->C) SubFNode( phase->makecon(TypeF::ZERO),in(2)->in(2));
}
// Cannot replace 0.0-X with -X because a 'fsub' bytecode computes
// 0.0-0.0 as +0.0, while a 'fneg' bytecode computes -0.0.
//if( phase->type(in(1)) == TypeF::ZERO )
*** 448,458 ****
--- 448,458 ----
// Not associative because of boundary conditions (infinity)
if( IdealizedNumerics && !phase->C->method()->is_strict() ) {
// Convert "x - (x+y)" into "-y"
if( in(2)->is_Add() &&
phase->eqv(in(1),in(2)->in(1) ) )
- return new (phase->C) SubDNode( phase->makecon(TypeD::ZERO),in(2)->in(2));
}
// Cannot replace 0.0-X with -X because a 'dsub' bytecode computes
// 0.0-0.0 as +0.0, while a 'dneg' bytecode computes -0.0.
//if( phase->type(in(1)) == TypeD::ZERO )
*** 579,593 ****
--- 579,593 ----
//------------------------------Idealize---------------------------------------
Node *CmpINode::Ideal( PhaseGVN *phase, bool can_reshape ) {
if (phase->type(in(2))->higher_equal(TypeInt::ZERO)) {
switch (in(1)->Opcode()) {
case Op_CmpL3: // Collapse a CmpL3/CmpI into a CmpL
- return new (phase->C) CmpLNode(in(1)->in(1),in(1)->in(2));
case Op_CmpF3: // Collapse a CmpF3/CmpI into a CmpF
- return new (phase->C) CmpFNode(in(1)->in(1),in(1)->in(2));
case Op_CmpD3: // Collapse a CmpD3/CmpI into a CmpD
- return new (phase->C) CmpDNode(in(1)->in(1),in(1)->in(2));
//case Op_SubI:
// If (x - y) cannot overflow, then ((x - y) <?> 0)
// can be turned into (x <?> y).
// This is handled (with more general cases) by Ideal_sub_algebra.
}
*** 1022,1033 ****
--- 1022,1033 ----
Node *tmp = new_in1;
new_in1 = new_in2;
new_in2 = tmp;
}
CmpFNode *new_cmp = (Opcode() == Op_CmpD3)
- ? new (phase->C) CmpF3Node( new_in1, new_in2 )
- : new (phase->C) CmpFNode ( new_in1, new_in2 ) ;
return new_cmp; // Changed to CmpFNode
}
// Testing value required the precision of a double
}
return NULL; // No change
*** 1095,1107 ****
--- 1095,1107 ----
return phase->transform( bol->negate(phase) );
}
// Else fall through. The CMove gets in the way of the test.
// It should be the case that make_predicate(bol->as_int_value()) == bol.
}
- Node* cmp = new (C) CmpINode(test_value, phase->intcon(0));
cmp = phase->transform(cmp);
- Node* bol = new (C) BoolNode(cmp, BoolTest::ne);
return phase->transform(bol);
}
//--------------------------------as_int_value---------------------------------
Node* BoolNode::as_int_value(PhaseGVN* phase) {
*** 1113,1123 ****
--- 1113,1123 ----
}
//----------------------------------negate-------------------------------------
BoolNode* BoolNode::negate(PhaseGVN* phase) {
Compile* C = phase->C;
- return new (C) BoolNode(in(1), _test.negate());
}
//------------------------------Ideal------------------------------------------
Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) {
*** 1151,1161 ****
--- 1151,1161 ----
// Clone the Node, getting a new Node of the same class
cmp = cmp->clone();
// Swap inputs to the clone
cmp->swap_edges(1, 2);
cmp = phase->transform( cmp );
- return new (phase->C) BoolNode( cmp, _test.commute() );
}
// Change "bool eq/ne (cmp (xor X 1) 0)" into "bool ne/eq (cmp X 0)".
// The XOR-1 is an idiom used to flip the sense of a bool. We flip the
// test instead.
*** 1168,1216 ****
--- 1168,1216 ----
j_xor->in(1) != j_xor && // An xor of itself is dead
phase->type( j_xor->in(1) ) == TypeInt::BOOL &&
phase->type( j_xor->in(2) ) == TypeInt::ONE &&
(_test._test == BoolTest::eq ||
_test._test == BoolTest::ne) ) {
- Node *ncmp = phase->transform(new (phase->C) CmpINode(j_xor->in(1),cmp2));
- return new (phase->C) BoolNode( ncmp, _test.negate() );
}
// Change "bool eq/ne (cmp (Conv2B X) 0)" into "bool eq/ne (cmp X 0)".
// This is a standard idiom for branching on a boolean value.
Node *c2b = cmp1;
if( cmp2_type == TypeInt::ZERO &&
cmp1_op == Op_Conv2B &&
(_test._test == BoolTest::eq ||
_test._test == BoolTest::ne) ) {
Node *ncmp = phase->transform(phase->type(c2b->in(1))->isa_int()
- ? (Node*)new (phase->C) CmpINode(c2b->in(1),cmp2)
- : (Node*)new (phase->C) CmpPNode(c2b->in(1),phase->makecon(TypePtr::NULL_PTR))
);
- return new (phase->C) BoolNode( ncmp, _test._test );
}
// Comparing a SubI against a zero is equal to comparing the SubI
// arguments directly. This only works for eq and ne comparisons
// due to possible integer overflow.
if ((_test._test == BoolTest::eq || _test._test == BoolTest::ne) &&
(cop == Op_CmpI) &&
(cmp1->Opcode() == Op_SubI) &&
( cmp2_type == TypeInt::ZERO ) ) {
- Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(1),cmp1->in(2)));
- return new (phase->C) BoolNode( ncmp, _test._test );
}
// Change (-A vs 0) into (A vs 0) by commuting the test. Disallow in the
// most general case because negating 0x80000000 does nothing. Needed for
// the CmpF3/SubI/CmpI idiom.
if( cop == Op_CmpI &&
cmp1->Opcode() == Op_SubI &&
cmp2_type == TypeInt::ZERO &&
phase->type( cmp1->in(1) ) == TypeInt::ZERO &&
phase->type( cmp1->in(2) )->higher_equal(TypeInt::SYMINT) ) {
- Node *ncmp = phase->transform( new (phase->C) CmpINode(cmp1->in(2),cmp2));
- return new (phase->C) BoolNode( ncmp, _test.commute() );
}
// The transformation below is not valid for either signed or unsigned
// comparisons due to wraparound concerns at MAX_VALUE and MIN_VALUE.
// This transformation can be resurrected when we are able to
src/share/vm/opto/subnode.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File