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

C2: Forbid GCM to move stores into loops

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b08

      Description

      Currently, GCM considers it legal to move stores into inner loops, and relies on the frequency-based heuristic in PhaseCFG::hoist_to_cheaper_block() to prevents such movements from happening.

      Moving a store into an inner loop should be however seen as illegal, as it breaks the invariant that, after GCM, memory definitions should not interfere. For example:

      Original placement of store in B1 (loop L1):

      B1 (L1):
        m1 <- ..
        m2 <- store m1, ..
      B2 (L2):
        jump B2
      B3 (L1):
        .. <- .. m2, ..

      Wrong "hoisting" of store to B2 (in loop L2, child of L1):

      B1 (L1):
        m1 <- ..
      B2 (L2):
        m2 <- store m1, ..
        # Wrong: m1 and m2 interfere at this point.
        jump B2
      B3 (L1):
        .. <- .. m2, ..

      Currently, such illegal movements are prevented by pinning stores to their original block, if the CFG is irreducible; and by the properties of the frequency estimation heuristic, if the CFG is reducible. This RFE proposes discarding the illegal movements beforehand, so that decisions that affect correctness are not left to the heuristic's discretion. More specifically, stores and other memory-defining nodes should not be allowed to move into deeper loops than the ones they originally belong to.

      The method testReducible() in test/hotspot/jtreg/compiler/codegen/TestGCMStorePlacement.java illustrates the issue: GCM considers moving counter++ into the loop, and only the frequency estimation heuristic prevents it from happening.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rcastanedalo Roberto Castaneda Lozano
              Reporter:
              rcastanedalo Roberto Castaneda Lozano
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: