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

C2: simplify anti-dependence check in PhaseCFG::implicit_null_check()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • 17
    • hotspot
    • b24

      The following loop in PhaseCFG::implicit_null_check() is guaranteed to run for exactly one iteration, and could be simplified accordingly:

            // mach use (faulting) trying to hoist
            // n might be blocker to hoisting
            while( b != block ) {
              ...
              b = get_block_for_node(b->pred(1)); // Move up to predecessor block
            }

      The reason is that, before the loop, 'block' (the null-check block) is guaranteed to be the direct predecessor of 'b' (the memory operation block). This invariant follows from earlier code in the same function, which ensures that 'block' is the immediate dominator of 'b' if 'b's memory operation is a store (for clarity, 'b' refers here to the memory operation block, instead of the original 'cb'):

          // Check ctrl input to see if the null-check dominates the memory op
          Block *b = get_block_for_node(mach);
          b = b->_idom; // Always hoist at least 1 block
          if( !was_store ) { // Stores can be hoisted only one block
            ...
            }
          }
          if( b != block ) continue;

      Due to the null-check shape of 'block' (where its successors cannot re-join), the fact that 'block' is the immediate dominator of 'b' implies 'block' is also the direct predecessor of 'b'.

            macarte Mat Carter
            rcastanedalo Roberto Castaneda Lozano
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: