|
29 | 29 |
|
30 | 30 | /*
|
31 | 31 | * @test
|
32 |
| - * @bug 8259609 8276116 |
| 32 | + * @bug 8259609 8276116 8311932 |
33 | 33 | * @summary C2: optimize long range checks in long counted loops
|
34 | 34 | * @library /test/lib /
|
35 | 35 | * @requires vm.compiler2.enabled
|
|
38 | 38 |
|
39 | 39 | public class TestLongRangeChecks {
|
40 | 40 | public static void main(String[] args) {
|
41 |
| - TestFramework.runWithFlags("-XX:-UseCountedLoopSafepoints"); |
42 |
| - TestFramework.runWithFlags("-XX:+UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=1"); |
43 |
| - TestFramework.runWithFlags("-XX:+UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=1000"); |
| 41 | + TestFramework.runWithFlags("-XX:+TieredCompilation", "-XX:-UseCountedLoopSafepoints", "-XX:LoopUnrollLimit=0"); |
| 42 | + TestFramework.runWithFlags("-XX:+TieredCompilation", "-XX:+UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=1", "-XX:LoopUnrollLimit=0"); |
| 43 | + TestFramework.runWithFlags("-XX:+TieredCompilation", "-XX:+UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=1000", "-XX:LoopUnrollLimit=0"); |
44 | 44 | }
|
45 | 45 |
|
46 | 46 |
|
@@ -246,4 +246,58 @@ public static void testStridePosScaleNegInIntLoop2(int start, int stop, long len
|
246 | 246 | private void testStridePosScaleNegInIntLoop2_runner() {
|
247 | 247 | testStridePosScaleNegInIntLoop2(0, 100, 200, 198);
|
248 | 248 | }
|
| 249 | + |
| 250 | + @Test |
| 251 | + @IR(counts = { IRNode.LONG_COUNTED_LOOP, "1" }) |
| 252 | + @IR(failOn = { IRNode.COUNTED_LOOP, IRNode.LOOP }) |
| 253 | + public static void testStridePosScalePosShortLoop(long start, long stop, long length, long offset) { |
| 254 | + final long scale = 1; |
| 255 | + final long stride = 1; |
| 256 | + |
| 257 | + // Loop runs for too few iterations. Transforming it wouldn't pay off. |
| 258 | + for (long i = start; i < stop; i += stride) { |
| 259 | + Objects.checkIndex(scale * i + offset, length); |
| 260 | + } |
| 261 | + } |
| 262 | + |
| 263 | + @Run(test = "testStridePosScalePosShortLoop") |
| 264 | + private void testStridePosScalePosShortLoop_runner() { |
| 265 | + testStridePosScalePosShortLoop(0, 2, 2, 0); |
| 266 | + } |
| 267 | + |
| 268 | + @Test |
| 269 | + @IR(counts = { IRNode.COUNTED_LOOP, "1" }) |
| 270 | + @IR(failOn = { IRNode.LOOP }) |
| 271 | + public static void testStridePosScalePosInIntLoopShortLoop1(int start, int stop, long length, long offset) { |
| 272 | + final long scale = 2; |
| 273 | + final int stride = 1; |
| 274 | + |
| 275 | + // Same but with int loop |
| 276 | + for (int i = start; i < stop; i += stride) { |
| 277 | + Objects.checkIndex(scale * i + offset, length); |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + @Run(test = "testStridePosScalePosInIntLoopShortLoop1") |
| 282 | + private void testStridePosScalePosInIntLoopShortLoop1_runner() { |
| 283 | + testStridePosScalePosInIntLoopShortLoop1(0, 2, 4, 0); |
| 284 | + } |
| 285 | + |
| 286 | + @Test |
| 287 | + @IR(counts = { IRNode.COUNTED_LOOP, "1" }) |
| 288 | + @IR(failOn = { IRNode.LOOP }) |
| 289 | + public static void testStridePosScalePosInIntLoopShortLoop2(long length, long offset) { |
| 290 | + final long scale = 2; |
| 291 | + final int stride = 1; |
| 292 | + |
| 293 | + // Same but with int loop |
| 294 | + for (int i = 0; i < 3; i += stride) { |
| 295 | + Objects.checkIndex(scale * i + offset, length); |
| 296 | + } |
| 297 | + } |
| 298 | + |
| 299 | + @Run(test = "testStridePosScalePosInIntLoopShortLoop2") |
| 300 | + private void testStridePosScalePosInIntLoopShortLoop2_runner() { |
| 301 | + testStridePosScalePosInIntLoopShortLoop2(6, 0); |
| 302 | + } |
249 | 303 | }
|
0 commit comments