--- a/hotspot/src/share/vm/opto/subnode.cpp Tue Sep 30 15:53:55 2008 -0700
+++ b/hotspot/src/share/vm/opto/subnode.cpp Thu Oct 02 08:37:44 2008 -0700
@@ -206,6 +206,14 @@
if( op1 == Op_AddI && op2 == Op_AddI && in1->in(2) == in2->in(2) )
return new (phase->C, 3) 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, 3) 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, 3) 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) {