C2: Load node not sunk out of loop when Store in loop body

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 27
    • Component/s: hotspot

      Load in loop body is not sunk out of loop even though it could be.

      If the Store is commented out, then the Load is sunk as expected.

      It seems anti-dependence analysis is too conservative. Possible fix:

      diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp
      index dacc1a1a734..d066e252487 100644
      --- a/src/hotspot/share/opto/loopnode.cpp
      +++ b/src/hotspot/share/opto/loopnode.cpp
      @@ -6514,7 +6514,7 @@ Node* PhaseIdealLoop::get_late_ctrl_with_anti_dep(LoadNode* n, Node* early, Node
             } else {
               Node* sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
               assert(sctrl != nullptr || !s->is_reachable_from_root(), "must have control");
      - if (sctrl != nullptr && !sctrl->is_top() && is_dominator(early, sctrl)) {
      + if (sctrl != nullptr && !sctrl->is_top() && is_dominator(LCA, sctrl)) {
                 const TypePtr* adr_type = s->adr_type();
                 if (s->is_ArrayCopy()) {
                   // Copy to known instance needs destination type to test for aliasing
      @@ -6551,7 +6551,7 @@ Node* PhaseIdealLoop::get_late_ctrl_with_anti_dep(LoadNode* n, Node* early, Node
                   Node* in = s->in(j);
                   Node* r_in = r->in(j);
                   // We can't reach any node from a Phi because we don't enqueue Phi's uses above
      - if (((worklist.member(in) && !in->is_Phi()) || in == mem) && is_dominator(early, r_in)) {
      + if (((worklist.member(in) && !in->is_Phi()) || in == mem) && is_dominator(LCA, r_in)) {
                     LCA = dom_lca_for_get_late_ctrl(LCA, r_in, n);
                   }
                 }

            Assignee:
            Roland Westrelin
            Reporter:
            Roland Westrelin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: