< prev index next >

test/compiler/codegen/BMI1.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


   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 8031321
  27  * @summary Support BMI1 instructions on x86/x64
  28  * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:CompileCommand=compileonly,BMITests.* BMI1
  29  *



  30  */
  31 
  32 class MemI {
  33   public int x;
  34   public MemI(int x) { this.x = x; }
  35 }
  36 
  37 class MemL {
  38   public long x;
  39   public MemL(long x) { this.x = x; }
  40 }
  41 
  42 class BMITests {
  43   static int andnl(int src1, int src2) {
  44     return ~src1 & src2;
  45   }
  46   static long andnq(long src1, long src2) {
  47     return ~src1 & src2;
  48   }
  49   static int andnl(int src1, MemI src2) {
  50     return ~src1 & src2.x;
  51   }
  52   static long andnq(long src1, MemL src2) {
  53     return ~src1 & src2.x;
  54   }
  55   static int blsil(int src1) {
  56     return src1 & -src1;
  57   }
  58   static long blsiq(long src1) {
  59     return src1 & -src1;
  60   }
  61   static int blsil(MemI src1) {
  62     return src1.x & -src1.x;
  63   }
  64   static long blsiq(MemL src1) {
  65     return src1.x & -src1.x;
  66   }
  67   static int blsmskl(int src1) {
  68     return (src1 - 1) ^ src1;
  69   }
  70   static long blsmskq(long src1) {
  71     return (src1 - 1) ^ src1;
  72   }
  73   static int blsmskl(MemI src1) {
  74     return (src1.x - 1) ^ src1.x;
  75   }
  76   static long blsmskq(MemL src1) {
  77     return (src1.x - 1) ^ src1.x;
  78   }
  79   static int blsrl(int src1) {
  80     return (src1 - 1) & src1;
  81   }
  82   static long blsrq(long src1) {
  83     return (src1 - 1) & src1;
  84   }
  85   static int blsrl(MemI src1) {
  86     return (src1.x - 1) & src1.x;
  87   }
  88   static long blsrq(MemL src1) {
  89     return (src1.x - 1) & src1.x;
  90   }
  91   static int lzcntl(int src1) {
  92     return Integer.numberOfLeadingZeros(src1);
  93   }
  94   static int lzcntq(long src1) {
  95     return Long.numberOfLeadingZeros(src1);
  96   }
  97   static int tzcntl(int src1) {
  98     return Integer.numberOfTrailingZeros(src1);
  99   }
 100   static int tzcntq(long src1) {
 101     return Long.numberOfTrailingZeros(src1);
 102   }
 103 }
 104 
 105 public class BMI1 {
 106   private final static int ITERATIONS = 1000000;
 107 
 108   public static void main(String[] args) {
 109     int ix = 0x01234567;
 110     int iy = 0x89abcdef;
 111     MemI imy = new MemI(iy);
 112     long lx = 0x0123456701234567L;
 113     long ly = 0x89abcdef89abcdefL;
 114     MemL lmy = new MemL(ly);
 115 
 116     { // match(Set dst (AndI (XorI src1 minus_1) src2))
 117       int z = BMITests.andnl(ix, iy);
 118       for (int i = 0; i < ITERATIONS; i++) {
 119         int ii = BMITests.andnl(ix, iy);
 120         if (ii != z) {
 121           throw new Error("andnl with register failed");
 122         }
 123       }
 124     }


 281 
 282     {
 283       int z = BMITests.tzcntl(ix);
 284       for (int i = 0; i < ITERATIONS; i++) {
 285         int ii = BMITests.tzcntl(ix);
 286         if (ii != z) {
 287           throw new Error("tzcntl failed");
 288         }
 289       }
 290     }
 291     {
 292       int z = BMITests.tzcntq(lx);
 293       for (int i = 0; i < ITERATIONS; i++) {
 294         int ii = BMITests.tzcntq(lx);
 295         if (ii != z) {
 296           throw new Error("tzcntq failed");
 297         }
 298       }
 299     }
 300   }


































































































 301 }


   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 8031321
  27  * @summary Support BMI1 instructions on x86/x64

  28  *
  29  * @run main/othervm -Xbatch -XX:-TieredCompilation
  30  *      -XX:CompileCommand=compileonly,compiler.codegen.BMI1$BMITests::*
  31  *      compiler.codegen.BMI1
  32  */
  33 
  34 package compiler.codegen;



  35 




































































  36 public class BMI1 {
  37     private final static int ITERATIONS = 1000000;
  38 
  39     public static void main(String[] args) {
  40         int ix = 0x01234567;
  41         int iy = 0x89abcdef;
  42         MemI imy = new MemI(iy);
  43         long lx = 0x0123456701234567L;
  44         long ly = 0x89abcdef89abcdefL;
  45         MemL lmy = new MemL(ly);
  46 
  47         { // match(Set dst (AndI (XorI src1 minus_1) src2))
  48             int z = BMITests.andnl(ix, iy);
  49             for (int i = 0; i < ITERATIONS; i++) {
  50                 int ii = BMITests.andnl(ix, iy);
  51                 if (ii != z) {
  52                     throw new Error("andnl with register failed");
  53                 }
  54             }
  55         }


 212 
 213         {
 214             int z = BMITests.tzcntl(ix);
 215             for (int i = 0; i < ITERATIONS; i++) {
 216                 int ii = BMITests.tzcntl(ix);
 217                 if (ii != z) {
 218                     throw new Error("tzcntl failed");
 219                 }
 220             }
 221         }
 222         {
 223             int z = BMITests.tzcntq(lx);
 224             for (int i = 0; i < ITERATIONS; i++) {
 225                 int ii = BMITests.tzcntq(lx);
 226                 if (ii != z) {
 227                     throw new Error("tzcntq failed");
 228                 }
 229             }
 230         }
 231     }
 232 
 233     static class MemI {
 234         public int x;
 235 
 236         public MemI(int x) {
 237             this.x = x;
 238         }
 239     }
 240 
 241     static class MemL {
 242         public long x;
 243 
 244         public MemL(long x) {
 245             this.x = x;
 246         }
 247     }
 248 
 249     static class BMITests {
 250         static int andnl(int src1, int src2) {
 251             return ~src1 & src2;
 252         }
 253 
 254         static long andnq(long src1, long src2) {
 255             return ~src1 & src2;
 256         }
 257 
 258         static int andnl(int src1, MemI src2) {
 259             return ~src1 & src2.x;
 260         }
 261 
 262         static long andnq(long src1, MemL src2) {
 263             return ~src1 & src2.x;
 264         }
 265 
 266         static int blsil(int src1) {
 267             return src1 & -src1;
 268         }
 269 
 270         static long blsiq(long src1) {
 271             return src1 & -src1;
 272         }
 273 
 274         static int blsil(MemI src1) {
 275             return src1.x & -src1.x;
 276         }
 277 
 278         static long blsiq(MemL src1) {
 279             return src1.x & -src1.x;
 280         }
 281 
 282         static int blsmskl(int src1) {
 283             return (src1 - 1) ^ src1;
 284         }
 285 
 286         static long blsmskq(long src1) {
 287             return (src1 - 1) ^ src1;
 288         }
 289 
 290         static int blsmskl(MemI src1) {
 291             return (src1.x - 1) ^ src1.x;
 292         }
 293 
 294         static long blsmskq(MemL src1) {
 295             return (src1.x - 1) ^ src1.x;
 296         }
 297 
 298         static int blsrl(int src1) {
 299             return (src1 - 1) & src1;
 300         }
 301 
 302         static long blsrq(long src1) {
 303             return (src1 - 1) & src1;
 304         }
 305 
 306         static int blsrl(MemI src1) {
 307             return (src1.x - 1) & src1.x;
 308         }
 309 
 310         static long blsrq(MemL src1) {
 311             return (src1.x - 1) & src1.x;
 312         }
 313 
 314         static int lzcntl(int src1) {
 315             return Integer.numberOfLeadingZeros(src1);
 316         }
 317 
 318         static int lzcntq(long src1) {
 319             return Long.numberOfLeadingZeros(src1);
 320         }
 321 
 322         static int tzcntl(int src1) {
 323             return Integer.numberOfTrailingZeros(src1);
 324         }
 325 
 326         static int tzcntq(long src1) {
 327             return Long.numberOfTrailingZeros(src1);
 328         }
 329     }
 330 }
< prev index next >