8264020: Optimize double negation elimination
Reviewed-by: thartmann, chagedorn
This commit is contained in:
parent
4ffa41c3db
commit
f3726a8700
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -235,9 +235,10 @@ Node *SubINode::Ideal(PhaseGVN *phase, bool can_reshape){
|
||||
return new SubINode(phase->intcon(0), in2->in(1));
|
||||
}
|
||||
|
||||
// Convert "0 - (x-y)" into "y-x"
|
||||
if( t1 == TypeInt::ZERO && op2 == Op_SubI )
|
||||
return new SubINode( in2->in(2), in2->in(1) );
|
||||
// Convert "0 - (x-y)" into "y-x", leave the double negation "-(-y)" to SubNode::Identity().
|
||||
if (t1 == TypeInt::ZERO && op2 == Op_SubI && phase->type(in2->in(1)) != TypeInt::ZERO) {
|
||||
return new SubINode(in2->in(2), in2->in(1));
|
||||
}
|
||||
|
||||
// Convert "0 - (x+con)" into "-con-x"
|
||||
jint con;
|
||||
@ -373,9 +374,10 @@ Node *SubLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
return new 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 SubLNode( in2->in(2), in2->in(1) );
|
||||
// Convert "0 - (x-y)" into "y-x", leave the double negation "-(-y)" to SubNode::Identity.
|
||||
if (t1 == TypeLong::ZERO && op2 == Op_SubL && phase->type(in2->in(1)) != TypeLong::ZERO) {
|
||||
return new 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) )
|
||||
|
Loading…
Reference in New Issue
Block a user