src/share/vm/c1/c1_LinearScan.cpp

Print this page
rev 4136 : 7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by:

@@ -6229,15 +6229,17 @@
           LIR_Op* prev_op = instructions->at(instructions->length() - 2);
           if (prev_op->code() == lir_branch || prev_op->code() == lir_cond_float_branch) {
             assert(prev_op->as_OpBranch() != NULL, "branch must be of type LIR_OpBranch");
             LIR_OpBranch* prev_branch = (LIR_OpBranch*)prev_op;
 
+            if (prev_branch->stub() == NULL) {
+
             LIR_Op2* prev_cmp = NULL;
 
             for(int j = instructions->length() - 3; j >= 0 && prev_cmp == NULL; j--) {
               prev_op = instructions->at(j);
-              if(prev_op->code() == lir_cmp) {
+                if (prev_op->code() == lir_cmp) {
                 assert(prev_op->as_Op2() != NULL, "branch must be of type LIR_Op2");
                 prev_cmp = (LIR_Op2*)prev_op;
                 assert(prev_branch->cond() == prev_cmp->condition(), "should be the same");
               }
             }

@@ -6254,10 +6256,11 @@
             }
           }
         }
       }
     }
+    }
   }
 
   DEBUG_ONLY(verify(code));
 }