test/hotspot/jtreg/compiler/loopopts/Test7044738.java
author jiangli
Fri, 02 Nov 2018 19:30:31 -0400
changeset 52397 1322829d1501
parent 47216 71c04702a3d5
permissions -rw-r--r--
8209564: runtime/appcds/CDSandJFR.java timeout on tier6 on sparc Summary: Set timeout 500 in CDSandJFR.java Reviewed-by: dcubed
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
 * @test
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    26
 * @bug 7044738
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    27
 * @summary Loop unroll optimization causes incorrect result
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    28
 *
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    29
 * @run main/othervm -Xbatch compiler.loopopts.Test7044738
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    30
 */
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    31
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    32
package compiler.loopopts;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    33
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    34
public class Test7044738 {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    35
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    36
    private static final int INITSIZE = 10000;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    37
    public int d[] = {1, 2, 3, 4};
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    38
    public int i, size;
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    39
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    40
    private static int iter = 5;
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    41
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    42
    boolean done() {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    43
        return (--iter > 0);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    44
    }
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    45
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    46
    public static void main(String args[]) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    47
        Test7044738 t = new Test7044738();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    48
        t.test();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    49
    }
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    50
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    51
    int test() {
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    52
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    53
        while (done()) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    54
            size = INITSIZE;
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    55
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    56
            for (i = 0; i < size; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    57
                d[0] = d[1]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    58
                d[1] = d[2]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    59
                d[2] = d[3]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    60
                d[3] = d[0]; // 2
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    61
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    62
                d[0] = d[1]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    63
                d[1] = d[2]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    64
                d[2] = d[3]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    65
                d[3] = d[0]; // 3
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    66
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    67
                d[0] = d[1]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    68
                d[1] = d[2]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    69
                d[2] = d[3]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    70
                d[3] = d[0]; // 4
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    71
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    72
                d[0] = d[1]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    73
                d[1] = d[2]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    74
                d[2] = d[3]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    75
                d[3] = d[0]; // 2
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    76
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    77
                d[0] = d[1]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    78
                d[1] = d[2]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    79
                d[2] = d[3]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    80
                d[3] = d[0]; // 3
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    81
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    82
                d[0] = d[1]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    83
                d[1] = d[2]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    84
                d[2] = d[3]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    85
                d[3] = d[0]; // 4
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    86
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    87
                d[0] = d[1]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    88
                d[1] = d[2]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    89
                d[2] = d[3]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    90
                d[3] = d[0]; // 2
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    91
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    92
                d[0] = d[1]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    93
                d[1] = d[2]; // 4
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    94
                d[2] = d[3]; // 2
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    95
                d[3] = d[0]; // 3
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    96
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    97
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    98
            // try to defeat dead code elimination
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    99
            if (d[0] == d[1]) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
   100
                System.out.println("test failed: iter=" + iter + "  i=" + i + " d[] = { " + d[0] + ", " + d[1] + ", " + d[2] + ", " + d[3] + " } ");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
   101
                System.exit(97);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
   102
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
   103
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
   104
        return d[3];
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   105
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
   106
}