< prev index next >

test/hotspot/jtreg/compiler/c2/TestBit.java

Print this page

 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 package compiler.c2;
 25 
 26 import jdk.test.lib.process.OutputAnalyzer;
 27 import jdk.test.lib.process.ProcessTools;
 28 
 29 /*
 30  * @test
 31  * @bug 8247408
 32  * @summary C2 should convert ((var&16) == 16) to ((var&16) != 0) for power-of-two constants
 33  * @library /test/lib /
 34  *
 35  * @requires vm.flagless
 36  * @requires os.arch=="aarch64" | os.arch=="amd64" | os.arch == "ppc64le"
 37  * @requires vm.debug == true & vm.compiler2.enabled
 38  *
 39  * @run driver compiler.c2.TestBit
 40  */
 41 public class TestBit {
 42 
 43     static void runTest(String testName) throws Exception {
 44         String className = TestBit.class.getName();
 45         String[] procArgs = {
 46             "-Xbatch",
 47             "-XX:-TieredCompilation",
 48             "-XX:+PrintOptoAssembly",
 49             "-XX:CompileCommand=compileonly," + className + "::tst*",
 50             className, testName};
 51 
 52         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
 53         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 54 
 55         String expectedTestBitInstruction =
 56             "ppc64le".equals(System.getProperty("os.arch")) ? "ANDI" :
 57             "aarch64".equals(System.getProperty("os.arch")) ? "tb"   :
 58             "amd64".equals(System.getProperty("os.arch"))   ? "test" : null;

 59 
 60         if (expectedTestBitInstruction != null) {
 61             output.shouldContain(expectedTestBitInstruction);
 62         } else {
 63             System.err.println("unexpected os.arch");
 64         }
 65     }
 66 
 67     static final int ITER = 100000; // ~ Tier4CompileThreshold + compilation time
 68 
 69     // dummy volatile variable
 70     public static volatile long c = 0;
 71 
 72     // C2 is expected to generate test bit instruction on the test
 73     static void tstBitLong(long value) {
 74         if (1L == (1L & value)) {
 75             c++;
 76         } else {
 77             c--;
 78         }

 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 package compiler.c2;
 25 
 26 import jdk.test.lib.process.OutputAnalyzer;
 27 import jdk.test.lib.process.ProcessTools;
 28 
 29 /*
 30  * @test
 31  * @bug 8247408
 32  * @summary C2 should convert ((var&16) == 16) to ((var&16) != 0) for power-of-two constants
 33  * @library /test/lib /
 34  *
 35  * @requires vm.flagless
 36  * @requires os.arch=="aarch64" | os.arch=="amd64" | os.arch == "ppc64le" | os.arch == "riscv64"
 37  * @requires vm.debug == true & vm.compiler2.enabled
 38  *
 39  * @run driver compiler.c2.TestBit
 40  */
 41 public class TestBit {
 42 
 43     static void runTest(String testName) throws Exception {
 44         String className = TestBit.class.getName();
 45         String[] procArgs = {
 46             "-Xbatch",
 47             "-XX:-TieredCompilation",
 48             "-XX:+PrintOptoAssembly",
 49             "-XX:CompileCommand=compileonly," + className + "::tst*",
 50             className, testName};
 51 
 52         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(procArgs);
 53         OutputAnalyzer output = new OutputAnalyzer(pb.start());
 54 
 55         String expectedTestBitInstruction =
 56             "ppc64le".equals(System.getProperty("os.arch")) ? "ANDI" :
 57             "aarch64".equals(System.getProperty("os.arch")) ? "tb"   :
 58             "amd64".equals(System.getProperty("os.arch"))   ? "test" :
 59             "riscv64".equals(System.getProperty("os.arch")) ? "andi" : null;
 60 
 61         if (expectedTestBitInstruction != null) {
 62             output.shouldContain(expectedTestBitInstruction);
 63         } else {
 64             System.err.println("unexpected os.arch");
 65         }
 66     }
 67 
 68     static final int ITER = 100000; // ~ Tier4CompileThreshold + compilation time
 69 
 70     // dummy volatile variable
 71     public static volatile long c = 0;
 72 
 73     // C2 is expected to generate test bit instruction on the test
 74     static void tstBitLong(long value) {
 75         if (1L == (1L & value)) {
 76             c++;
 77         } else {
 78             c--;
 79         }
< prev index next >