test/hotspot/jtreg/compiler/c2/TestBitSetAndReset.java
changeset 59051 f0312c7d5b37
equal deleted inserted replaced
59050:7bbaa3c416e7 59051:f0312c7d5b37
       
     1 /*
       
     2  * Copyright (c) 2019 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  * @test
       
    26  * @bug 8214239
       
    27  * @summary Missing x86_64.ad patterns for clearing and setting long vector bits
       
    28  *
       
    29  * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
       
    30  *                   -XX:-TieredCompilation -XX:CompileThreshold=1000
       
    31  *                   -XX:CompileCommand=print,compiler/c2/TestBitSetAndReset.test*
       
    32  *                   -XX:CompileCommand=compileonly,compiler/c2/TestBitSetAndReset.test*
       
    33  *                   -XX:CompileCommand=dontinline,compiler/c2/TestBitSetAndReset.test*
       
    34  *                   compiler.c2.TestBitSetAndReset
       
    35  */
       
    36 
       
    37 package compiler.c2;
       
    38 
       
    39 public class TestBitSetAndReset {
       
    40     private static final int COUNT = 10_000;
       
    41 
       
    42     private static final long MASK63 = 0x8000_0000_0000_0000L;
       
    43     private static final long MASK32 = 0x0000_0001_0000_0000L;
       
    44     private static final long MASK31 = 0x0000_0000_8000_0000L;
       
    45     private static final long MASK15 = 0x0000_0000_0000_8000L;
       
    46     private static final long MASK00 = 0x0000_0000_0000_0001L;
       
    47 
       
    48     private static long andq, orq;
       
    49 
       
    50     public static void main(String... args) {
       
    51         boolean success = true;
       
    52 
       
    53         for (int i=0; i<COUNT; i++) {
       
    54             andq = MASK63 | MASK31 | MASK15 | MASK00;
       
    55             orq = 0;
       
    56             test63();
       
    57             test32();
       
    58             test31();
       
    59             test15();
       
    60             test00();
       
    61             success &= andq == 0 && orq == (MASK63 | MASK32 | MASK31 | MASK15 | MASK00);
       
    62         }
       
    63         if (!success)
       
    64             throw new AssertionError("Failure while setting or clearing long vector bits!");
       
    65     }
       
    66 
       
    67     private static void test63() {
       
    68         andq &= ~MASK63;
       
    69         orq |= MASK63;
       
    70     }
       
    71     private static void test32() {
       
    72         andq &= ~MASK32;
       
    73         orq |= MASK32;
       
    74     }
       
    75     private static void test31() {
       
    76         andq &= ~MASK31;
       
    77         orq |= MASK31;
       
    78     }
       
    79     private static void test15() {
       
    80         andq &= ~MASK15;
       
    81         orq |= MASK15;
       
    82     }
       
    83     private static void test00() {
       
    84         andq &= ~MASK00;
       
    85         orq |= MASK00;
       
    86     }
       
    87 }