Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/6443505/Test6443505.java
32285 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324/**25* @test26* @bug 644350527* @summary Some cases for CmpLTMask missed; also wrong code.28*29* @run main/othervm -Xcomp -XX:CompileOnly="Test6443505.compiled" Test644350530*/3132public class Test6443505 {3334public static void main(String[] args) throws InterruptedException {35test(Integer.MIN_VALUE, 0);36test(0, Integer.MIN_VALUE);37test(Integer.MIN_VALUE, -1);38test(-1, Integer.MIN_VALUE);39test(Integer.MIN_VALUE, 1);40test(1, Integer.MIN_VALUE);4142test(Integer.MAX_VALUE, 0);43test(0, Integer.MAX_VALUE);44test(Integer.MAX_VALUE, -1);45test(-1, Integer.MAX_VALUE);46test(Integer.MAX_VALUE, 1);47test(1, Integer.MAX_VALUE);4849test(Integer.MIN_VALUE, Integer.MAX_VALUE);50test(Integer.MAX_VALUE, Integer.MIN_VALUE);5152test(1, -1);53test(1, 0);54test(1, 1);55test(-1, -1);56test(-1, 0);57test(-1, 1);58test(0, -1);59test(0, 0);60test(0, 1);61}6263public static void test(int a, int b) throws InterruptedException {64int C = compiled(4, a, b);65int I = interpreted(4, a, b);66if (C != I) {67System.err.println("#1 C = " + C + ", I = " + I);68System.err.println("#1 C != I, FAIL");69System.exit(97);70}7172C = compiled(a, b, q, 4);73I = interpreted(a, b, q, 4);74if (C != I) {75System.err.println("#2 C = " + C + ", I = " + I);76System.err.println("#2 C != I, FAIL");77System.exit(97);78}7980}8182static int q = 4;8384// If improperly compiled, uses carry/borrow bit, which is wrong.85// with -XX:+PrintOptoAssembly, look for cadd_cmpLTMask86static int compiled(int p, int x, int y) {87return (x < y) ? q + (x - y) : (x - y);88}8990// interpreted reference91static int interpreted(int p, int x, int y) {92return (x < y) ? q + (x - y) : (x - y);93}9495// Test new code with a range of cases96// with -XX:+PrintOptoAssembly, look for and_cmpLTMask97static int compiled(int x, int y, int q, int p) {98return (x < y) ? p + q : q;99}100101// interpreted reference102static int interpreted(int x, int y, int q, int p) {103return (x < y) ? p + q : q;104}105106}107108109