hotspot/test/compiler/loopopts/superword/TestReductionWithLoopVariantUse.java
author chegar
Tue, 22 Mar 2016 15:26:07 +0000
changeset 36694 182a5e7a519e
parent 31048 ad1dfe0256a7
child 40059 c2304140ed64
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31048
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     1
/*
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     4
 *
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     8
 *
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    13
 * accompanied this code).
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    14
 *
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    18
 *
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    21
 * questions.
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    22
 */
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    23
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    24
/*
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    25
 * @test
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    26
 * @bug 8080976
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    27
 * @summary Loop variant use in reduction should prevent vectorization
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    28
 * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestReductionWithLoopVariantUse
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    29
 *
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    30
 */
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    31
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    32
public class TestReductionWithLoopVariantUse {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    33
    static int m(int[] array) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    34
        int c = 0;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    35
        for (int i = 0; i < 256; i++) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    36
            c += array[i];
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    37
            array[i] = c;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    38
        }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    39
        return c;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    40
    }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    41
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    42
    static public void main(String[] args) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    43
        int[] array = new int[256];
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    44
        int[] array2 = new int[256];
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    45
        for (int j = 0; j < 256; j++) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    46
            array2[j] = j;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    47
        }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    48
        for (int i = 0; i < 20000; i++) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    49
            System.arraycopy(array2, 0, array, 0, 256);
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    50
            int res = m(array);
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    51
            boolean success = true;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    52
            int c = 0;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    53
            for (int j = 0; j < 256; j++) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    54
                c += array2[j];
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    55
                if (array[j] != c) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    56
                    System.out.println("Failed for " + j + " : " + array[j] + " != " + c);
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    57
                    success = false;
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    58
                }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    59
            }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    60
            if (c != res) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    61
                System.out.println("Failed for sum: " + c + " != " + res);
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    62
            }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    63
            if (!success) {
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    64
                throw new RuntimeException("Test failed");
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    65
            }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    66
        }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    67
    }
ad1dfe0256a7 8080976: Unexpected AIOOB thrown from 1.9.0-ea-b64 on (regression)
roland
parents:
diff changeset
    68
}