hotspot/test/compiler/loopopts/ConstFPVectorization.java
author chegar
Tue, 22 Mar 2016 15:26:07 +0000
changeset 36694 182a5e7a519e
parent 29581 b8d83fef0c8e
child 40059 c2304140ed64
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29581
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     1
/*
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     4
 *
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     8
 *
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    13
 * accompanied this code).
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    14
 *
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    18
 *
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    21
 * questions.
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    22
 *
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    23
 */
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    24
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    25
/**
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    26
 * @test
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    27
 * @bug 8074869
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    28
 * @summary C2 code generator can replace -0.0f with +0.0f on Linux
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    29
 * @run main ConstFPVectorization 8
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    30
 * @author volker.simonis@gmail.com
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    31
 *
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    32
 */
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    33
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    34
public class ConstFPVectorization {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    35
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    36
    static float[] f = new float[16];
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    37
    static double[] d = new double[16];
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    38
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    39
    static void floatLoop(int count) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    40
        for (int i = 0; i < count; i++) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    41
            f[i] = -0.0f;
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    42
        }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    43
    }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    44
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    45
    static void doubleLoop(int count) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    46
        for (int i = 0; i < count; i++) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    47
            d[i] = -0.0d;
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    48
        }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    49
    }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    50
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    51
    public static void main(String args[]) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    52
        for (int i = 0; i < 10_000; i++) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    53
            floatLoop(Integer.parseInt(args[0]));
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    54
            doubleLoop(Integer.parseInt(args[0]));
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    55
        }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    56
        for (int i = 0; i < Integer.parseInt(args[0]); i++) {
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    57
            if (Float.floatToRawIntBits(f[i]) != Float.floatToRawIntBits(-0.0f))
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    58
                throw new Error("Float error at index " + i);
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    59
            if (Double.doubleToRawLongBits(d[i]) != Double.doubleToRawLongBits(-0.0d))
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    60
                throw new Error("Double error at index " + i);
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    61
        }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    62
    }
b8d83fef0c8e 8074869: C2 code generator can replace -0.0f with +0.0f on Linux
zmajo
parents:
diff changeset
    63
}