hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java
author duke
Wed, 05 Jul 2017 19:51:52 +0200 (2017-07-05)
changeset 25650 de3462562eaa
parent 22911 ff49c48c887d
child 27453 9aeb9b97bef6
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     1
/*
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     4
 *
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     8
 *
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    13
 * accompanied this code).
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    14
 *
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    18
 *
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    21
 * questions.
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    22
 */
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    23
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    24
/*
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    25
 * @test
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    26
 * @bug 8025657
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    27
 * @summary Test repeating addExact
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    28
 * @compile AddExactIRepeatTest.java Verify.java
22911
ff49c48c887d 8027754: Enable loop optimizations for loops with MathExact inside
rbackman
parents: 21920
diff changeset
    29
 * @run main AddExactIRepeatTest
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    30
 *
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    31
 */
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    32
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    33
public class AddExactIRepeatTest {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    34
    public static void main(String[] args) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    35
        runTest(new Verify.AddExactI());
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    36
    }
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    37
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    38
    public static int nonExact(int x, int y, Verify.BinaryMethod method) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    39
        int result = method.unchecked(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    40
        result += method.unchecked(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    41
        result += method.unchecked(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    42
        result += method.unchecked(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    43
        return result;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    44
    }
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    45
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    46
    public static void runTest(Verify.BinaryMethod method) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    47
        java.util.Random rnd = new java.util.Random();
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    48
        for (int i = 0; i < 50000; ++i) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    49
            int x = Integer.MAX_VALUE - 10;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    50
            int y = Integer.MAX_VALUE - 10 + rnd.nextInt(5);
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    51
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    52
            int c = rnd.nextInt() / 2;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    53
            int d = rnd.nextInt() / 2;
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    54
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    55
            int a = catchingExact(x, y, method);
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    56
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    57
            if (a != 36) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    58
                throw new RuntimeException("a != 36 : " + a);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    59
            }
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    60
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    61
            int b = nonExact(c, d, method);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    62
            int n = exact(c, d, method);
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    63
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    64
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    65
            if (n != b) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    66
                throw new RuntimeException("n != b : " + n + " != " + b);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    67
            }
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    68
        }
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    69
    }
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    70
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    71
    public static int exact(int x, int y, Verify.BinaryMethod method) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    72
        int result = 0;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    73
        result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    74
        result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    75
        result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    76
        result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    77
        return result;
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    78
    }
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
    79
21105
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    80
    public static int catchingExact(int x, int y, Verify.BinaryMethod method) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    81
        int result = 0;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    82
        try {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    83
            result += 5;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    84
            result = method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    85
        } catch (ArithmeticException e) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    86
            result += 1;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    87
        }
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    88
        try {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    89
            result += 6;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    90
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    91
            result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    92
        } catch (ArithmeticException e) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    93
            result += 2;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    94
        }
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    95
        try {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    96
            result += 7;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    97
            result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    98
        } catch (ArithmeticException e) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
    99
            result += 3;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   100
        }
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   101
        try {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   102
            result += 8;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   103
            result += method.checkMethod(x, y);
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   104
        } catch (ArithmeticException e) {
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   105
            result += 4;
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   106
        }
47618ee96ed5 8026844: Various Math functions needs intrinsification
rbackman
parents: 20715
diff changeset
   107
        return result;
20715
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
   108
    }
be1135dc1406 8025657: compiler/intrinsics/mathexact/ConstantTest.java fails on assert in lcm.cpp on solaris x64
rbackman
parents:
diff changeset
   109
}