@@ -60,6 +60,8 @@ public class Byte128VectorTests extends AbstractVectorTest {
60
60
static final int INVOC_COUNT = Integer .getInteger ("jdk.incubator.vector.test.loop-iterations" , 100 );
61
61
62
62
63
+ private static final byte CONST_SHIFT = Byte .SIZE / 2 ;
64
+
63
65
static final int BUFFER_REPS = Integer .getInteger ("jdk.incubator.vector.test.buffer-vectors" , 25000 / 128 );
64
66
65
67
interface FUnOp {
@@ -460,6 +462,50 @@ static void assertShiftArraysEquals(byte[] r, byte[] a, byte[] b, boolean[] mask
460
462
}
461
463
}
462
464
465
+ interface FBinConstOp {
466
+ byte apply (byte a );
467
+ }
468
+
469
+ interface FBinConstMaskOp {
470
+ byte apply (byte a , boolean m );
471
+
472
+ static FBinConstMaskOp lift (FBinConstOp f ) {
473
+ return (a , m ) -> m ? f .apply (a ) : a ;
474
+ }
475
+ }
476
+
477
+ static void assertShiftConstEquals (byte [] r , byte [] a , FBinConstOp f ) {
478
+ int i = 0 ;
479
+ int j = 0 ;
480
+ try {
481
+ for (; j < a .length ; j += SPECIES .length ()) {
482
+ for (i = 0 ; i < SPECIES .length (); i ++) {
483
+ Assert .assertEquals (r [i +j ], f .apply (a [i +j ]));
484
+ }
485
+ }
486
+ } catch (AssertionError e ) {
487
+ Assert .assertEquals (r [i +j ], f .apply (a [i +j ]), "at index #" + i + ", " + j );
488
+ }
489
+ }
490
+
491
+ static void assertShiftConstEquals (byte [] r , byte [] a , boolean [] mask , FBinConstOp f ) {
492
+ assertShiftConstEquals (r , a , mask , FBinConstMaskOp .lift (f ));
493
+ }
494
+
495
+ static void assertShiftConstEquals (byte [] r , byte [] a , boolean [] mask , FBinConstMaskOp f ) {
496
+ int i = 0 ;
497
+ int j = 0 ;
498
+ try {
499
+ for (; j < a .length ; j += SPECIES .length ()) {
500
+ for (i = 0 ; i < SPECIES .length (); i ++) {
501
+ Assert .assertEquals (r [i +j ], f .apply (a [i +j ], mask [i ]));
502
+ }
503
+ }
504
+ } catch (AssertionError err ) {
505
+ Assert .assertEquals (r [i +j ], f .apply (a [i +j ], mask [i ]), "at index #" + i + ", input1 = " + a [i +j ] + ", mask = " + mask [i ]);
506
+ }
507
+ }
508
+
463
509
interface FTernOp {
464
510
byte apply (byte a , byte b , byte c );
465
511
}
@@ -2554,7 +2600,7 @@ static void ROLByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte
2554
2600
2555
2601
2556
2602
static byte ROR_unary (byte a , byte b ) {
2557
- return (byte )(ROR_scalar (a ,b ));
2603
+ return (byte )(ROR_scalar (a , b ));
2558
2604
}
2559
2605
2560
2606
@ Test (dataProvider = "byteBinaryOpProvider" )
@@ -2596,7 +2642,7 @@ static void RORByte128VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFu
2596
2642
2597
2643
2598
2644
static byte ROL_unary (byte a , byte b ) {
2599
- return (byte )(ROL_scalar (a ,b ));
2645
+ return (byte )(ROL_scalar (a , b ));
2600
2646
}
2601
2647
2602
2648
@ Test (dataProvider = "byteBinaryOpProvider" )
@@ -2636,6 +2682,215 @@ static void ROLByte128VectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFu
2636
2682
assertShiftArraysEquals (r , a , b , mask , Byte128VectorTests ::ROL_unary );
2637
2683
}
2638
2684
2685
+
2686
+
2687
+
2688
+ static byte LSHR_binary_const (byte a ) {
2689
+ return (byte )(((a & 0xFF ) >>> CONST_SHIFT ));
2690
+ }
2691
+
2692
+ @ Test (dataProvider = "byteUnaryOpProvider" )
2693
+ static void LSHRByte128VectorTestsScalarShiftConst (IntFunction <byte []> fa ) {
2694
+ byte [] a = fa .apply (SPECIES .length ());
2695
+ byte [] r = fr .apply (SPECIES .length ());
2696
+
2697
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2698
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2699
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2700
+ av .lanewise (VectorOperators .LSHR , CONST_SHIFT ).intoArray (r , i );
2701
+ }
2702
+ }
2703
+
2704
+ assertShiftConstEquals (r , a , Byte128VectorTests ::LSHR_binary_const );
2705
+ }
2706
+
2707
+
2708
+
2709
+ @ Test (dataProvider = "byteUnaryOpMaskProvider" )
2710
+ static void LSHRByte128VectorTestsScalarShiftMaskedConst (IntFunction <byte []> fa ,
2711
+ IntFunction <boolean []> fm ) {
2712
+ byte [] a = fa .apply (SPECIES .length ());
2713
+ byte [] r = fr .apply (SPECIES .length ());
2714
+ boolean [] mask = fm .apply (SPECIES .length ());
2715
+ VectorMask <Byte > vmask = VectorMask .fromArray (SPECIES , mask , 0 );
2716
+
2717
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2718
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2719
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2720
+ av .lanewise (VectorOperators .LSHR , CONST_SHIFT , vmask ).intoArray (r , i );
2721
+ }
2722
+ }
2723
+
2724
+ assertShiftConstEquals (r , a , mask , Byte128VectorTests ::LSHR_binary_const );
2725
+ }
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+ static byte LSHL_binary_const (byte a ) {
2732
+ return (byte )((a << CONST_SHIFT ));
2733
+ }
2734
+
2735
+ @ Test (dataProvider = "byteUnaryOpProvider" )
2736
+ static void LSHLByte128VectorTestsScalarShiftConst (IntFunction <byte []> fa ) {
2737
+ byte [] a = fa .apply (SPECIES .length ());
2738
+ byte [] r = fr .apply (SPECIES .length ());
2739
+
2740
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2741
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2742
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2743
+ av .lanewise (VectorOperators .LSHL , CONST_SHIFT ).intoArray (r , i );
2744
+ }
2745
+ }
2746
+
2747
+ assertShiftConstEquals (r , a , Byte128VectorTests ::LSHL_binary_const );
2748
+ }
2749
+
2750
+
2751
+
2752
+ @ Test (dataProvider = "byteUnaryOpMaskProvider" )
2753
+ static void LSHLByte128VectorTestsScalarShiftMaskedConst (IntFunction <byte []> fa ,
2754
+ IntFunction <boolean []> fm ) {
2755
+ byte [] a = fa .apply (SPECIES .length ());
2756
+ byte [] r = fr .apply (SPECIES .length ());
2757
+ boolean [] mask = fm .apply (SPECIES .length ());
2758
+ VectorMask <Byte > vmask = VectorMask .fromArray (SPECIES , mask , 0 );
2759
+
2760
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2761
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2762
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2763
+ av .lanewise (VectorOperators .LSHL , CONST_SHIFT , vmask ).intoArray (r , i );
2764
+ }
2765
+ }
2766
+
2767
+ assertShiftConstEquals (r , a , mask , Byte128VectorTests ::LSHL_binary_const );
2768
+ }
2769
+
2770
+
2771
+
2772
+ static byte ASHR_binary_const (byte a ) {
2773
+ return (byte )((a >> CONST_SHIFT ));
2774
+ }
2775
+
2776
+ @ Test (dataProvider = "byteUnaryOpProvider" )
2777
+ static void ASHRByte128VectorTestsScalarShiftConst (IntFunction <byte []> fa ) {
2778
+ byte [] a = fa .apply (SPECIES .length ());
2779
+ byte [] r = fr .apply (SPECIES .length ());
2780
+
2781
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2782
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2783
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2784
+ av .lanewise (VectorOperators .ASHR , CONST_SHIFT ).intoArray (r , i );
2785
+ }
2786
+ }
2787
+
2788
+ assertShiftConstEquals (r , a , Byte128VectorTests ::ASHR_binary_const );
2789
+ }
2790
+
2791
+
2792
+
2793
+ @ Test (dataProvider = "byteUnaryOpMaskProvider" )
2794
+ static void ASHRByte128VectorTestsScalarShiftMaskedConst (IntFunction <byte []> fa ,
2795
+ IntFunction <boolean []> fm ) {
2796
+ byte [] a = fa .apply (SPECIES .length ());
2797
+ byte [] r = fr .apply (SPECIES .length ());
2798
+ boolean [] mask = fm .apply (SPECIES .length ());
2799
+ VectorMask <Byte > vmask = VectorMask .fromArray (SPECIES , mask , 0 );
2800
+
2801
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2802
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2803
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2804
+ av .lanewise (VectorOperators .ASHR , CONST_SHIFT , vmask ).intoArray (r , i );
2805
+ }
2806
+ }
2807
+
2808
+ assertShiftConstEquals (r , a , mask , Byte128VectorTests ::ASHR_binary_const );
2809
+ }
2810
+
2811
+
2812
+
2813
+ static byte ROR_binary_const (byte a ) {
2814
+ return (byte )(ROR_scalar (a , CONST_SHIFT ));
2815
+ }
2816
+
2817
+ @ Test (dataProvider = "byteUnaryOpProvider" )
2818
+ static void RORByte128VectorTestsScalarShiftConst (IntFunction <byte []> fa ) {
2819
+ byte [] a = fa .apply (SPECIES .length ());
2820
+ byte [] r = fr .apply (SPECIES .length ());
2821
+
2822
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2823
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2824
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2825
+ av .lanewise (VectorOperators .ROR , CONST_SHIFT ).intoArray (r , i );
2826
+ }
2827
+ }
2828
+
2829
+ assertShiftConstEquals (r , a , Byte128VectorTests ::ROR_binary_const );
2830
+ }
2831
+
2832
+
2833
+
2834
+ @ Test (dataProvider = "byteUnaryOpMaskProvider" )
2835
+ static void RORByte128VectorTestsScalarShiftMaskedConst (IntFunction <byte []> fa ,
2836
+ IntFunction <boolean []> fm ) {
2837
+ byte [] a = fa .apply (SPECIES .length ());
2838
+ byte [] r = fr .apply (SPECIES .length ());
2839
+ boolean [] mask = fm .apply (SPECIES .length ());
2840
+ VectorMask <Byte > vmask = VectorMask .fromArray (SPECIES , mask , 0 );
2841
+
2842
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2843
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2844
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2845
+ av .lanewise (VectorOperators .ROR , CONST_SHIFT , vmask ).intoArray (r , i );
2846
+ }
2847
+ }
2848
+
2849
+ assertShiftConstEquals (r , a , mask , Byte128VectorTests ::ROR_binary_const );
2850
+ }
2851
+
2852
+
2853
+
2854
+ static byte ROL_binary_const (byte a ) {
2855
+ return (byte )(ROL_scalar (a , CONST_SHIFT ));
2856
+ }
2857
+
2858
+ @ Test (dataProvider = "byteUnaryOpProvider" )
2859
+ static void ROLByte128VectorTestsScalarShiftConst (IntFunction <byte []> fa ) {
2860
+ byte [] a = fa .apply (SPECIES .length ());
2861
+ byte [] r = fr .apply (SPECIES .length ());
2862
+
2863
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2864
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2865
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2866
+ av .lanewise (VectorOperators .ROL , CONST_SHIFT ).intoArray (r , i );
2867
+ }
2868
+ }
2869
+
2870
+ assertShiftConstEquals (r , a , Byte128VectorTests ::ROL_binary_const );
2871
+ }
2872
+
2873
+
2874
+
2875
+ @ Test (dataProvider = "byteUnaryOpMaskProvider" )
2876
+ static void ROLByte128VectorTestsScalarShiftMaskedConst (IntFunction <byte []> fa ,
2877
+ IntFunction <boolean []> fm ) {
2878
+ byte [] a = fa .apply (SPECIES .length ());
2879
+ byte [] r = fr .apply (SPECIES .length ());
2880
+ boolean [] mask = fm .apply (SPECIES .length ());
2881
+ VectorMask <Byte > vmask = VectorMask .fromArray (SPECIES , mask , 0 );
2882
+
2883
+ for (int ic = 0 ; ic < INVOC_COUNT ; ic ++) {
2884
+ for (int i = 0 ; i < a .length ; i += SPECIES .length ()) {
2885
+ ByteVector av = ByteVector .fromArray (SPECIES , a , i );
2886
+ av .lanewise (VectorOperators .ROL , CONST_SHIFT , vmask ).intoArray (r , i );
2887
+ }
2888
+ }
2889
+
2890
+ assertShiftConstEquals (r , a , mask , Byte128VectorTests ::ROL_binary_const );
2891
+ }
2892
+
2893
+
2639
2894
static byte MIN (byte a , byte b ) {
2640
2895
return (byte )(Math .min (a , b ));
2641
2896
}
0 commit comments