Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8252496

C2: Useless code in MergeMemNode::Ideal

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 8, 11, 15, 16, 19
    • hotspot
    • b10

      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.

            epeter Emanuel Peter
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: