Details
-
Enhancement
-
Resolution: Unresolved
-
P4
-
11, 17, 21, 23
Description
The tests in test/hotspot/jtreg/compiler/rangechecks/TestExplicitRangeChecks.java exercise an optimization that folds together two range-check-like comparisons into a single, unsigned one. Currently, the tests check the correctness of the optimization, but do not assert that the optimization actually takes place. This RFE proposes adding such assertions using the IR test framework (for example, check that the optimized code contains the expected number of comparisons or uncommon traps). For example:
// Should be compiled as a single unsigned comparison
// 0 <= index < array.length
@Test
@IR(counts = {IRNode.RANGE_CHECK_TRAP, "1"})
@IR(failOn = IRNode.UNSTABLE_IF_TRAP)
static boolean test1_1(int index, int[] array) {
if (index < 0 || index >= array.length) {
return false;
}
return true;
}
The tests use jdk.test.whitebox functionality to e.g. assert that some calls to the compiled tests result or do not result in deoptimization. A similar effect could be achieved using functionality provided by the IR test framework, e.g. compiler.lib.ir_framework.TestFramework::assertDeoptimizedByC2(Method m).
// Should be compiled as a single unsigned comparison
// 0 <= index < array.length
@Test
@IR(counts = {IRNode.RANGE_CHECK_TRAP, "1"})
@IR(failOn = IRNode.UNSTABLE_IF_TRAP)
static boolean test1_1(int index, int[] array) {
if (index < 0 || index >= array.length) {
return false;
}
return true;
}
The tests use jdk.test.whitebox functionality to e.g. assert that some calls to the compiled tests result or do not result in deoptimization. A similar effect could be achieved using functionality provided by the IR test framework, e.g. compiler.lib.ir_framework.TestFramework::assertDeoptimizedByC2(Method m).
Attachments
Issue Links
- relates to
-
JDK-8073480 C2 should optimize explicit range checks
- Resolved