hotspot/test/compiler/7046096/Test7046096.java
author adlertz
Fri, 24 Jan 2014 13:06:52 +0100
changeset 22804 401135897b65
parent 10011 e8b38f7b9959
permissions -rw-r--r--
8031498: Cleanup and re-factorize PhaseChaitin::build_ifg_physical Summary: Created sub-functions, added data structures, improved naming and removed unnecessary code Reviewed-by: kvn, roland, rbackman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10011
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     1
/*
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     4
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     8
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    13
 * accompanied this code).
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    14
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    18
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    21
 * questions.
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    22
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    23
 */
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    24
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    25
/**
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    26
 * @test
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    27
 * @bug 7046096
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    28
 * @summary SEGV IN C2 WITH 6U25
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    29
 *
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    30
 * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeStringConcat Test7046096
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    31
 */
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    32
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    33
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    34
public class Test7046096 {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    35
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    36
  static int first = 1;
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    37
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    38
  String add(String str) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    39
    if (first != 0) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    40
      return str + "789";
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    41
    } else {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    42
      return "null";
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    43
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    44
  }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    45
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    46
  String test(String str) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    47
    for (int i=0; i < first; i++) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    48
      if (i > 1)
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    49
        return "bad";
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    50
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    51
    return add(str+"456");
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    52
  }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    53
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    54
  public static void main(String [] args) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    55
    Test7046096 t = new Test7046096();
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    56
    for (int i = 0; i < 11000; i++) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    57
      String str = t.test("123");
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    58
      if (!str.equals("123456789")) {
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    59
        System.out.println("FAILED: " + str + " != \"123456789\"");
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    60
        System.exit(97);
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    61
      }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    62
    }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    63
  }
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    64
}
e8b38f7b9959 7044738: Loop unroll optimization causes incorrect result
kvn
parents:
diff changeset
    65