JDK-8252496 : C2: Useless code in MergeMemNode::Ideal
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8,11,15,16,19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-08-28
  • Updated: 2022-02-17
  • Resolved: 2022-02-10
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
19 b10Fixed
Related Reports
Relates :  
Description
CLion says phi_reg and phi_len are unused after the block below:

  // Look carefully at the base node if it is a phi.
  PhiNode* phi_base;
  if (new_base != NULL && new_base->is_Phi())
    phi_base = new_base->as_Phi();
  else
    phi_base = NULL;

  Node*    phi_reg = NULL;
  uint     phi_len = (uint)-1;
  if (phi_base != NULL && !phi_base->is_copy()) {
    // do not examine phi if degraded to a copy
    phi_reg = phi_base->region();
    phi_len = phi_base->req();
    // see if the phi is unfinished
    for (uint i = 1; i < phi_len; i++) {
      if (phi_base->in(i) == NULL) {
        // incomplete phi; do not look at it yet!
        phi_reg = NULL;
        phi_len = (uint)-1;
        break;
      }
    }
  }

It seems the entire thing, including phi_base is unused. The only reason I could find is reaching for asserts in is_copy(), region(), etc. In that case, the block can be wrapped in ASSERT to avoid useless walk in production code. If this block is not even for asserts, we can prune it.

This and surrounding code seems to be the same since the initial load.
Comments
Changeset: fa0a72c0 Author: Emanuel Peter <emanuel.peter@oracle.com> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2022-02-10 09:29:53 +0000 URL: https://git.openjdk.java.net/jdk/commit/fa0a72c030432f9ea4ad9913a2bb4096324410aa
10-02-2022

This looks like a cleanup job for JDK-8243670
09-02-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7401 Date: 2022-02-09 09:23:50 +0000
09-02-2022

Hi [~cslucas], are you currently working on this or could that be reassigned?
07-02-2022

Another place: MergeMemNode::memory_at defines C as Compile::current() but never use it.
03-02-2022