hotspot/test/compiler/intrinsics/mathexact/GVNTest.java
author rbackman
Tue, 12 Nov 2013 14:52:48 +0100
changeset 21578 d380e7e6f805
child 21920 7b7c52305d6a
permissions -rw-r--r--
8028207: assert(_outcnt==1) failed: not unique in compile.cpp Reviewed-by: iveresov, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21578
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     1
/*
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     4
 *
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     8
 *
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    13
 * accompanied this code).
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    14
 *
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    18
 *
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    21
 * questions.
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    22
 */
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    23
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    24
/*
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    25
 * @test
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    26
 * @bug 8028207
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    27
 * @summary Verify that GVN doesn't mess up the two addExacts
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    28
 * @compile GVNTest.java
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    29
 * @run main GVNTest
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    30
 *
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    31
 */
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    32
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    33
public class GVNTest {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    34
  public static int result = 0;
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    35
  public static int value = 93;
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    36
  public static void main(String[] args) {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    37
    for (int i = 0; i < 50000; ++i) {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    38
      result = runTest(value + i);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    39
      result = runTest(value + i);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    40
      result = runTest(value + i);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    41
      result = runTest(value + i);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    42
      result = runTest(value + i);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    43
    }
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    44
  }
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    45
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    46
  public static int runTest(int value) {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    47
    int v = value + value;
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    48
    int sum = 0;
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    49
    if (v < 4032) {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    50
      for (int i = 0; i < 1023; ++i) {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    51
        sum += Math.addExact(value, value);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    52
      }
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    53
    } else {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    54
      for (int i = 0; i < 321; ++i) {
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    55
        sum += Math.addExact(value, value);
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    56
      }
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    57
    }
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    58
    return sum + v;
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    59
  }
d380e7e6f805 8028207: assert(_outcnt==1) failed: not unique in compile.cpp
rbackman
parents:
diff changeset
    60
}