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

Problem in compress_expand_identity

    XMLWordPrintable

Details

    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.

      Attachments

        Issue Links

          Activity

            People

              jbhateja Jatin Bhateja
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: