test/compiler/6636138/Test1.java

Tue, 24 Mar 2009 12:19:47 -0700

author
cfang
date
Tue, 24 Mar 2009 12:19:47 -0700
changeset 1102
78af5ae8e731
child 1146
9610b2a8ab4e
permissions
-rw-r--r--

6636138: UseSuperWord enabled failure
Summary: Fixed SuperWord scheduling of memory operations.
Reviewed-by: kvn, never

cfang@1102 1 /*
cfang@1102 2 * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
cfang@1102 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cfang@1102 4 *
cfang@1102 5 * This code is free software; you can redistribute it and/or modify it
cfang@1102 6 * under the terms of the GNU General Public License version 2 only, as
cfang@1102 7 * published by the Free Software Foundation.
cfang@1102 8 *
cfang@1102 9 * This code is distributed in the hope that it will be useful, but WITHOUT
cfang@1102 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cfang@1102 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
cfang@1102 12 * version 2 for more details (a copy is included in the LICENSE file that
cfang@1102 13 * accompanied this code).
cfang@1102 14 *
cfang@1102 15 * You should have received a copy of the GNU General Public License version
cfang@1102 16 * 2 along with this work; if not, write to the Free Software Foundation,
cfang@1102 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cfang@1102 18 *
cfang@1102 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
cfang@1102 20 * CA 95054 USA or visit www.sun.com if you need additional information or
cfang@1102 21 * have any questions.
cfang@1102 22 */
cfang@1102 23
cfang@1102 24 /**
cfang@1102 25 * @test
cfang@1102 26 * @bug 6636138
cfang@1102 27 * @summary SuperWord::co_locate_pack(Node_List* p) generates memory graph that leads to memory order violation.
cfang@1102 28 *
cfang@1102 29 * @run main/othervm -server -Xbatch -XX:CompileOnly=Test1.init -XX:+UseSuperword Test1
cfang@1102 30 */
cfang@1102 31
cfang@1102 32 class Test1 {
cfang@1102 33
cfang@1102 34 public static void init(int src[], int [] dst, int[] ref) {
cfang@1102 35 // initialize the arrays
cfang@1102 36 for (int i =0; i<src.length; i++) {
cfang@1102 37 src[i] = i;
cfang@1102 38 dst[i] = 2; // yes, dst[i] needed(otherwise src[i] will be replaced with i)
cfang@1102 39 ref[i] = src[i]; // src[i] depends on the store src[i]
cfang@1102 40 }
cfang@1102 41 }
cfang@1102 42
cfang@1102 43 public static void verify(int src[], int[] ref) {
cfang@1102 44 // check whether src and ref are equal
cfang@1102 45 for (int i = 0; i < src.length; i++) {
cfang@1102 46 if (src[i] != ref[i]) {
cfang@1102 47 System.out.println("Error: src and ref don't match at " + i);
cfang@1102 48 System.exit(-1);
cfang@1102 49 }
cfang@1102 50 }
cfang@1102 51 }
cfang@1102 52
cfang@1102 53 public static void test() {
cfang@1102 54 int[] src = new int[34];
cfang@1102 55 int[] dst = new int[34];
cfang@1102 56 int[] ref = new int[34];
cfang@1102 57
cfang@1102 58 init(src, dst, ref);
cfang@1102 59 verify(src, ref);
cfang@1102 60 }
cfang@1102 61
cfang@1102 62 public static void main(String[] args) {
cfang@1102 63 for (int i=0; i< 2000; i++) {
cfang@1102 64 test();
cfang@1102 65 }
cfang@1102 66 }
cfang@1102 67 }

mercurial