United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6697236 missing Identity for "(X+Y) - X" into Y
JDK-6697236 : missing Identity for "(X+Y) - X" into Y

Details
Type:
Bug
Submit Date:
2008-05-02
Status:
Resolved
Updated Date:
2010-04-02
Project Name:
JDK
Resolved Date:
2008-07-02
Component:
hotspot
OS:
solaris_9
Sub-Component:
compiler
CPU:
sparc
Priority:
P4
Resolution:
Fixed
Affected Versions:
hs13
Fixed Versions:
hs14 (b01)

Related Reports
Backport:
Backport:

Sub Tasks

Description
C2 misses the identity "(X+Y) - X" into Y

                                    

Comments
SUGGESTED FIX

diff --git a/src/share/vm/opto/subnode.cpp b/src/share/vm/opto/subnode.cpp
--- a/src/share/vm/opto/subnode.cpp
+++ b/src/share/vm/opto/subnode.cpp
@@ -45,10 +45,13 @@ Node *SubNode::Identity( PhaseTransform
     return in(2)->in(2);
   }

-  // Convert "(X+Y) - Y" into X
+  // Convert "(X+Y) - Y" into X and "(X+Y) - X" into Y
   if( in(1)->Opcode() == Op_AddI ) {
     if( phase->eqv(in(1)->in(2),in(2)) )
       return in(1)->in(1);
+    if (phase->eqv(in(1)->in(1),in(2)))
+      return in(1)->in(2);
+
     // Also catch: "(X + Opaque2(Y)) - Y".  In this case, 'Y' is a loop-varying
     // trip counter and X is likely to be loop-invariant (that's how O2 Nodes
     // are originally used, although the optimizer sometimes jiggers things).
                                     
2008-05-02
EVALUATION

See suggested fix
                                     
2008-05-02



Hardware and Software, Engineered to Work Together