test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java
author roland
Tue, 12 Mar 2019 15:42:32 +0100
changeset 54119 6bf8877eb1b9
child 59063 058d299b22b6
permissions -rw-r--r--
8220374: C2: LoopStripMining doesn't strip as expected Reviewed-by: rkennke, thartmann, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54119
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     1
/*
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     2
 * Copyright (c) 2019, SAP SE. All rights reserved.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     4
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     8
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    13
 * accompanied this code).
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    14
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    18
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    21
 * questions.
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    22
 */
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    23
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    24
/**
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    25
 * @test
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    26
 * @bug 8220374
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    27
 * @summary C2: LoopStripMining doesn't strip as expected
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    28
 * @requires vm.compiler2.enabled
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    29
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    30
 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+SafepointTimeout -XX:+SafepointALot
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    31
 *                   -XX:+AbortVMOnSafepointTimeout -XX:SafepointTimeoutDelay=500 -XX:GuaranteedSafepointInterval=500
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    32
 *                   -XX:-TieredCompilation -XX:+UseCountedLoopSafepoints -XX:LoopStripMiningIter=1000
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    33
 *                   -XX:LoopUnrollLimit=0 -XX:CompileCommand=compileonly,CheckLoopStripMining::test_loop -Xcomp CheckLoopStripMining
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    34
 *
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    35
 */
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    36
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    37
public class CheckLoopStripMining {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    38
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    39
  public static int test_loop(int x) {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    40
      int sum = 0;
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    41
      if (x != 0) {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    42
          for (int y = 1; y < Integer.MAX_VALUE; ++y) {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    43
              if (y % x == 0) ++sum;
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    44
          }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    45
      }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    46
      return sum;
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    47
  }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    48
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    49
  public static void main(String args[]) {
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    50
    int sum = test_loop(3);
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    51
    System.out.println("sum: " + sum);
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    52
  }
6bf8877eb1b9 8220374: C2: LoopStripMining doesn't strip as expected
roland
parents:
diff changeset
    53
}