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

C2: Should not create Loop Limit Check Predicate when bailing out of is_counted_loop()

XMLWordPrintable

      There could be cases, where we add a Loop Limit Check Predicate with insert_loop_limit_check_predicate() but later, we bail out of is_counted_loop(). For example, by setting -XX:StressLongCountedLoop or when having a safepoint on the backedge (https://github.com/openjdk/jdk/blob/087887286d575107c076605e1027b553939c3836/src/hotspot/share/opto/loopnode.cpp#L1901-L1911, triggered by attached test).

      We could end up adding multiple Loop Limit Check Predicates for a single loop and/or having a Loop Limit Check Predicate for a LoopNode (non-counted) which could lead to unnecessary deoptimizations/re-compilations.

      Even though this is an edge case, we should probably fix that.

      To run TestLoopLimitCheckNonCountedLoop.java, we require the following new IR Node:

      diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java
      index def34bb4ac6..1475f5d6677 100644
      --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java
      +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java
      @@ -619,6 +619,11 @@ public class IRNode {
               fromBeforeCountedLoops(LOOP, regex);
           }
       
      + public static final String LOOP_LIMIT_CHECK_TRAP = PREFIX + "LOOP_LIMIT_CHECK_TRAP" + POSTFIX;
      + static {
      + trapNodes(LOOP_LIMIT_CHECK_TRAP, "loop_limit_check");
      + }
      +
           public static final String LSHIFT = PREFIX + "LSHIFT" + POSTFIX;
           static {
               beforeMatchingNameRegex(LSHIFT, "LShift(I|L)");

            chagedorn Christian Hagedorn
            chagedorn Christian Hagedorn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: