2955N/A/*
2955N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2955N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2955N/A *
2955N/A * This code is free software; you can redistribute it and/or modify it
2955N/A * under the terms of the GNU General Public License version 2 only, as
2955N/A * published by the Free Software Foundation.
2955N/A *
2955N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2955N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2955N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2955N/A * version 2 for more details (a copy is included in the LICENSE file that
2955N/A * accompanied this code).
2955N/A *
2955N/A * You should have received a copy of the GNU General Public License version
2955N/A * 2 along with this work; if not, write to the Free Software Foundation,
2955N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2955N/A *
2955N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2955N/A * or visit www.oracle.com if you need additional information or have any
2955N/A * questions.
2955N/A *
2955N/A */
2955N/A
2955N/A/**
2955N/A * @test
2955N/A * @bug 7110586
2955N/A * @summary C2 generates icorrect results
2955N/A *
2955N/A * @run main/othervm -Xbatch Test7110586
2955N/A */
2955N/A
2955N/Apublic class Test7110586 {
2955N/A static int test1() {
2955N/A int i = 0;
2955N/A for ( ; i < 11; i+=1) {}
2955N/A return i;
2955N/A }
2955N/A static int test2() {
2955N/A int i = 0;
2955N/A for ( ; i < 11; i+=2) {}
2955N/A return i;
2955N/A }
2955N/A static int test3() {
2955N/A int i = 0;
2955N/A for ( ; i < 11; i+=3) {}
2955N/A return i;
2955N/A }
2955N/A static int test11() {
2955N/A int i = 0;
2955N/A for ( ; i < 11; i+=11) {}
2955N/A return i;
2955N/A }
2955N/A
2955N/A static int testm1() {
2955N/A int i = 0;
2955N/A for ( ; i > -11; i-=1) {}
2955N/A return i;
2955N/A }
2955N/A static int testm2() {
2955N/A int i = 0;
2955N/A for ( ; i > -11; i-=2) {}
2955N/A return i;
2955N/A }
2955N/A static int testm3() {
2955N/A int i = 0;
2955N/A for ( ; i > -11; i-=3) {}
2955N/A return i;
2955N/A }
2955N/A static int testm11() {
2955N/A int i = 0;
2955N/A for ( ; i > -11; i-=11) {}
2955N/A return i;
2955N/A }
2955N/A
2955N/A public static void main(String args[]) {
2955N/A int x1 = 0;
2955N/A int x2 = 0;
2955N/A int x3 = 0;
2955N/A int x11 = 0;
2955N/A int m1 = 0;
2955N/A int m2 = 0;
2955N/A int m3 = 0;
2955N/A int m11 = 0;
2955N/A for (int i=0; i<10000; i++) {
2955N/A x1 = test1();
2955N/A x2 = test2();
2955N/A x3 = test3();
2955N/A x11 = test11();
2955N/A m1 = testm1();
2955N/A m2 = testm2();
2955N/A m3 = testm3();
2955N/A m11 = testm11();
2955N/A }
2955N/A boolean failed = false;
2955N/A if (x1 != 11) {
2955N/A System.out.println("ERROR (incr = +1): " + x1 + " != 11");
2955N/A failed = true;
2955N/A }
2955N/A if (x2 != 12) {
2955N/A System.out.println("ERROR (incr = +2): " + x2 + " != 12");
2955N/A failed = true;
2955N/A }
2955N/A if (x3 != 12) {
2955N/A System.out.println("ERROR (incr = +3): " + x3 + " != 12");
2955N/A failed = true;
2955N/A }
2955N/A if (x11 != 11) {
2955N/A System.out.println("ERROR (incr = +11): " + x11 + " != 11");
2955N/A failed = true;
2955N/A }
2955N/A if (m1 != -11) {
2955N/A System.out.println("ERROR (incr = -1): " + m1 + " != -11");
2955N/A failed = true;
2955N/A }
2955N/A if (m2 != -12) {
2955N/A System.out.println("ERROR (incr = -2): " + m2 + " != -12");
2955N/A failed = true;
2955N/A }
2955N/A if (m3 != -12) {
2955N/A System.out.println("ERROR (incr = -3): " + m3 + " != -12");
2955N/A failed = true;
2955N/A }
2955N/A if (m11 != -11) {
2955N/A System.out.println("ERROR (incr = -11): " + m11 + " != -11");
2955N/A failed = true;
2955N/A }
2955N/A if (failed) {
2955N/A System.exit(97);
2955N/A }
2955N/A }
2955N/A}