hotspot/test/compiler/loopopts/7044738/Test7044738.java
author zmajo
Tue, 18 Nov 2014 19:44:45 +0100
changeset 27699 9913b19c0948
parent 10011 hotspot/test/compiler/7044738/Test7044738.java@e8b38f7b9959
permissions -rw-r--r--
8062854: move compiler jtreg test to corresponding subfolders and use those in TEST.groups Summary: move all test from <bug_id> directories to <functional_dir_name>/<bug_id>; update TEST.groups to execute more tests Reviewed-by: drchase, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     1
/*
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     4
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     8
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    13
 * accompanied this code).
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    14
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    18
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    21
 * questions.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    22
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    23
 */
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    24
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    25
/**
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    26
 * @test
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    27
 * @bug 7044738
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    28
 * @summary Loop unroll optimization causes incorrect result
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    29
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    30
 * @run main/othervm -Xbatch Test7044738
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    31
 */
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    32
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    33
public class Test7044738 {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    34
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    35
  private static final int INITSIZE = 10000;
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    36
  public int d[] = { 1, 2, 3, 4 };
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    37
  public int i, size;
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    38
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    39
  private static int iter = 5;
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    40
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    41
  boolean done() { return (--iter > 0); }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    42
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    43
  public static void main(String args[]) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    44
    Test7044738 t = new Test7044738();
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    45
    t.test();
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    46
  }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    47
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    48
  int test() {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    49
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    50
    while (done()) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    51
      size = INITSIZE;
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    52
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    53
      for (i = 0; i < size; i++) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    54
        d[0] = d[1]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    55
        d[1] = d[2]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    56
        d[2] = d[3]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    57
        d[3] = d[0]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    58
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    59
        d[0] = d[1]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    60
        d[1] = d[2]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    61
        d[2] = d[3]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    62
        d[3] = d[0]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    63
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    64
        d[0] = d[1]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    65
        d[1] = d[2]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    66
        d[2] = d[3]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    67
        d[3] = d[0]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    68
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    69
        d[0] = d[1]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    70
        d[1] = d[2]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    71
        d[2] = d[3]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    72
        d[3] = d[0]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    73
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    74
        d[0] = d[1]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    75
        d[1] = d[2]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    76
        d[2] = d[3]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    77
        d[3] = d[0]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    78
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    79
        d[0] = d[1]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    80
        d[1] = d[2]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    81
        d[2] = d[3]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    82
        d[3] = d[0]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    83
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    84
        d[0] = d[1]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    85
        d[1] = d[2]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    86
        d[2] = d[3]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    87
        d[3] = d[0]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    88
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    89
        d[0] = d[1]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    90
        d[1] = d[2]; // 4
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    91
        d[2] = d[3]; // 2
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    92
        d[3] = d[0]; // 3
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    93
      }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    94
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    95
      // try to defeat dead code elimination
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    96
      if (d[0] == d[1]) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    97
        System.out.println("test failed: iter=" + iter + "  i=" + i + " d[] = { " + d[0] + ", " + d[1] + ", " + d[2] + ", " + d[3] + " } ");
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    98
        System.exit(97);
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    99
      }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   100
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   101
    return d[3];
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   102
  }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   103
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   104
}