test/hotspot/jtreg/compiler/c2/Test7046096.java
author iignatyev
Mon, 18 Feb 2019 09:31:07 -0800
changeset 53791 bec6c8739833
parent 47216 71c04702a3d5
permissions -rw-r--r--
8219157: vm/mlvm/mixed/stress/java/findDeadlock should be problem-listed only on mac Reviewed-by: thartmann
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 7046096
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    27
 * @summary SEGV IN C2 WITH 6U25
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 -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeStringConcat
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    30
 *    compiler.c2.Test7046096
10011
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
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    33
package compiler.c2;
10011
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
public class Test7046096 {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    36
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    37
    static int first = 1;
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    38
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    39
    String add(String str) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    40
        if (first != 0) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    41
            return str + "789";
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    42
        } else {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    43
            return "null";
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
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    46
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    47
    String test(String str) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    48
        for (int i = 0; i < first; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    49
            if (i > 1)
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    50
                return "bad";
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    51
        }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    52
        return add(str + "456");
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    53
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    54
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    55
    public static void main(String[] args) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    56
        Test7046096 t = new Test7046096();
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    57
        for (int i = 0; i < 11000; i++) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    58
            String str = t.test("123");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    59
            if (!str.equals("123456789")) {
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    60
                System.out.println("FAILED: " + str + " != \"123456789\"");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    61
                System.exit(97);
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    62
            }
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 27699
diff changeset
    63
        }
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    64
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    65
}
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    66