JDK-8287855 : Problem in compress_expand_identity
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2022-06-06
  • Updated: 2022-07-05
  • Resolved: 2022-07-05
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 19
19Resolved
Related Reports
Duplicate :  
Relates :  
Description
SonarCloud reports: "code will never be executed" in compress_expand_identity

Node* compress_expand_identity(PhaseGVN* phase, Node* n) {
  BasicType bt = n->bottom_type()->basic_type();
  // compress(x, 0) == 0, expand(x, 0) == 0
  if(phase->type(n->in(2))->higher_equal(TypeInteger::zero(bt))) return n->in(2);
  // compress(x, -1) == x, expand(x, -1) == x
  if(phase->type(n->in(2))->higher_equal(TypeInteger::minus_1(bt))) return n->in(1);
  return n;
  // DEAD CODE FOLLOWS:
  // expand(-1, x) == x
  if(n->Opcode() == Op_ExpandBits &&
     phase->type(n->in(1))->higher_equal(TypeInteger::minus_1(bt))) return n->in(2);
  return n;
}

Note how "return n" is unconditional, which makes the rest of the code dead.
Comments
Problem has been fixed with following check-in:- https://github.com/openjdk/jdk19/commit/1a271645a84ac4d7d6570e739d42c05cc328891d
04-07-2022

This has been fixed with PR for JDK-8287851 which is under review. https://github.com/openjdk/jdk19/pull/104
02-07-2022

[~jbhateja] and [~sviswanathan] please look.
07-06-2022

ILW = dead code, may be hiding other errors; always; no workaround = LLH = P4
06-06-2022