JDK-6697236 : missing Identity for "(X+Y) - X" into Y
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_9
  • CPU: sparc
  • Submitted: 2008-05-02
  • Updated: 2010-04-02
  • Resolved: 2008-07-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u14Fixed 7Fixed hs14Fixed
Description
C2 misses the identity "(X+Y) - X" into Y

Comments
EVALUATION See suggested fix
02-05-2008

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).
02-05-2008