test/hotspot/jtreg/vmTestbase/vm/compiler/jbe/dead/dead15/dead15.java
author iignatyev
Fri, 01 Jun 2018 15:48:55 -0700
changeset 50366 4d85990f9c4a
permissions -rw-r--r--
8202812: [TESTBUG] Open source VM testbase compiler tests Reviewed-by: kvn, mseledtsov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50366
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     1
/*
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     4
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     8
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    14
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    18
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    21
 * questions.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    22
 */
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    23
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    24
/*
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    25
 * @test
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    26
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    27
 * @summary converted from VM Testbase runtime/jbe/dead/dead15.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    28
 * VM Testbase keywords: [quick, runtime]
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    29
 *
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    30
 * @library /vmTestbase
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    31
 *          /test/lib
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    32
 * @run driver jdk.test.lib.FileInstaller . .
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    33
 * @run main/othervm vm.compiler.jbe.dead.dead15.dead15
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    34
 */
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    35
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    36
package vm.compiler.jbe.dead.dead15;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    37
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    38
// dead15.java
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    39
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    40
/* -- Test the elimination of a global variable assignment to itself.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    41
      Example:
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    42
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    43
      int bar;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    44
      void foo()
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    45
      {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    46
         bar = bar;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    47
      }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    48
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    49
      The assignment to bar can be eliminated. Though assignments of this
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    50
      nature are unlikley to occur in an original code, it can actually
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    51
      happen as a result of other optimizations. For example, consider the
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    52
      following assignments after constant propagation.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    53
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    54
      bat = 0;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    55
      bar = bar + bat;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    56
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    57
      After constant propagation, the second statement becomes bar = bar + 0,
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    58
      or bar = bar.  This test ensures that the final transformation, (i.e.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    59
      the elimination of this assignment) will occur.
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    60
 */
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    61
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    62
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    63
public class dead15 {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    64
  int i00=0, i01=1, i02=2, i03=3, i04=4;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    65
  int i05=5, i06=6, i07=7, i08=8, i09=9;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    66
  int i10=10, i11=11, i12=12, i13=13, i14=14;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    67
  int i15=15, i16=16, i17=17, i18=18, i19=19;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    68
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    69
  public static void main(String args[]) {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    70
    dead15 dce = new dead15();
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    71
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    72
    System.out.println("f()="+dce.f()+"; fopt()="+dce.fopt());
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    73
    if (dce.f() == dce.fopt()) {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    74
      System.out.println("Test dead15 Passed.");
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    75
    } else {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    76
      throw new Error("Test dead15 Failed: f()=" + dce.f() + " != fopt()=" + dce.fopt());
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    77
    }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    78
  }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    79
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    80
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    81
  int f() {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    82
    i00 = i00;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    83
    i01 = i01;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    84
    i02 = i02;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    85
    i03 = i03;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    86
    i04 = i04;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    87
    i05 = i05;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    88
    i06 = i06;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    89
    i07 = i07;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    90
    i08 = i08;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    91
    i09 = i09;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    92
    i10 = i10;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    93
    i11 = i11;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    94
    i12 = i12;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    95
    i13 = i13;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    96
    i14 = i14;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    97
    i15 = i15;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    98
    i16 = i16;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
    99
    i17 = i17;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   100
    i18 = i18;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   101
    i19 = i19;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   102
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   103
    return i19;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   104
  }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   105
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   106
  // Code fragment after dead code elimination
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   107
  int fopt() {
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   108
    return i19;
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   109
  }
4d85990f9c4a 8202812: [TESTBUG] Open source VM testbase compiler tests
iignatyev
parents:
diff changeset
   110
}