Mercurial > hg > truffle
comparison test/compiler/7110586/Test7110586.java @ 4112:e8fdaf4a66cb
7110586: C2 generates incorrect results
Summary: Exact limit of empty loop calculated incorrectly.
Reviewed-by: iveresov, never
author | kvn |
---|---|
date | Thu, 10 Nov 2011 20:17:05 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
4065:78bef05801ca | 4112:e8fdaf4a66cb |
---|---|
1 /* | |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 /** | |
26 * @test | |
27 * @bug 7110586 | |
28 * @summary C2 generates icorrect results | |
29 * | |
30 * @run main/othervm -Xbatch Test7110586 | |
31 */ | |
32 | |
33 public class Test7110586 { | |
34 static int test1() { | |
35 int i = 0; | |
36 for ( ; i < 11; i+=1) {} | |
37 return i; | |
38 } | |
39 static int test2() { | |
40 int i = 0; | |
41 for ( ; i < 11; i+=2) {} | |
42 return i; | |
43 } | |
44 static int test3() { | |
45 int i = 0; | |
46 for ( ; i < 11; i+=3) {} | |
47 return i; | |
48 } | |
49 static int test11() { | |
50 int i = 0; | |
51 for ( ; i < 11; i+=11) {} | |
52 return i; | |
53 } | |
54 | |
55 static int testm1() { | |
56 int i = 0; | |
57 for ( ; i > -11; i-=1) {} | |
58 return i; | |
59 } | |
60 static int testm2() { | |
61 int i = 0; | |
62 for ( ; i > -11; i-=2) {} | |
63 return i; | |
64 } | |
65 static int testm3() { | |
66 int i = 0; | |
67 for ( ; i > -11; i-=3) {} | |
68 return i; | |
69 } | |
70 static int testm11() { | |
71 int i = 0; | |
72 for ( ; i > -11; i-=11) {} | |
73 return i; | |
74 } | |
75 | |
76 public static void main(String args[]) { | |
77 int x1 = 0; | |
78 int x2 = 0; | |
79 int x3 = 0; | |
80 int x11 = 0; | |
81 int m1 = 0; | |
82 int m2 = 0; | |
83 int m3 = 0; | |
84 int m11 = 0; | |
85 for (int i=0; i<10000; i++) { | |
86 x1 = test1(); | |
87 x2 = test2(); | |
88 x3 = test3(); | |
89 x11 = test11(); | |
90 m1 = testm1(); | |
91 m2 = testm2(); | |
92 m3 = testm3(); | |
93 m11 = testm11(); | |
94 } | |
95 boolean failed = false; | |
96 if (x1 != 11) { | |
97 System.out.println("ERROR (incr = +1): " + x1 + " != 11"); | |
98 failed = true; | |
99 } | |
100 if (x2 != 12) { | |
101 System.out.println("ERROR (incr = +2): " + x2 + " != 12"); | |
102 failed = true; | |
103 } | |
104 if (x3 != 12) { | |
105 System.out.println("ERROR (incr = +3): " + x3 + " != 12"); | |
106 failed = true; | |
107 } | |
108 if (x11 != 11) { | |
109 System.out.println("ERROR (incr = +11): " + x11 + " != 11"); | |
110 failed = true; | |
111 } | |
112 if (m1 != -11) { | |
113 System.out.println("ERROR (incr = -1): " + m1 + " != -11"); | |
114 failed = true; | |
115 } | |
116 if (m2 != -12) { | |
117 System.out.println("ERROR (incr = -2): " + m2 + " != -12"); | |
118 failed = true; | |
119 } | |
120 if (m3 != -12) { | |
121 System.out.println("ERROR (incr = -3): " + m3 + " != -12"); | |
122 failed = true; | |
123 } | |
124 if (m11 != -11) { | |
125 System.out.println("ERROR (incr = -11): " + m11 + " != -11"); | |
126 failed = true; | |
127 } | |
128 if (failed) { | |
129 System.exit(97); | |
130 } | |
131 } | |
132 } |