< prev index next >

test/jdk/jdk/incubator/vector/Short64VectorTests.java

Print this page
rev 55894 : 8222897: [vector] Renaming of shift, rotate operations. Few other api changes.
Summary: Renaming of shift, rotate operations. Few other api changes.
Reviewed-by: jrose, briangoetz


 645         short[] r = fr.apply(SPECIES.length());
 646         boolean[] mask = fm.apply(SPECIES.length());
 647         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 648 
 649         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 650             for (int i = 0; i < a.length; i += SPECIES.length()) {
 651                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 652                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 653                 av.xor(bv, vmask).intoArray(r, i);
 654             }
 655         }
 656 
 657         assertArraysEquals(a, b, r, mask, Short64VectorTests::xor);
 658     }
 659 
 660 
 661 
 662 
 663 
 664 



 665 





 666 







 667 


 668 
 669 
 670 
















 671 


 672 
 673 
 674 
 675 
 676 
 677 



 678 
 679     static short aShiftR_unary(short a, short b) {
 680         return (short)((a >> (b & 15)));












































 681     }
 682 
 683     @Test(dataProvider = "shortBinaryOpProvider")
 684     static void aShiftRShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 685         short[] a = fa.apply(SPECIES.length());
 686         short[] b = fb.apply(SPECIES.length());
 687         short[] r = fr.apply(SPECIES.length());
 688 
 689         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 690             for (int i = 0; i < a.length; i += SPECIES.length()) {
 691                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 692                 av.aShiftR((int)b[i]).intoArray(r, i);

 693             }
 694         }
 695 
 696         assertShiftArraysEquals(a, b, r, Short64VectorTests::aShiftR_unary);
 697     }
 698 
 699 
 700 
 701     @Test(dataProvider = "shortBinaryOpMaskProvider")
 702     static void aShiftRShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb,
 703                                           IntFunction<boolean[]> fm) {
 704         short[] a = fa.apply(SPECIES.length());
 705         short[] b = fb.apply(SPECIES.length());
 706         short[] r = fr.apply(SPECIES.length());
 707         boolean[] mask = fm.apply(SPECIES.length());
 708         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 709 
 710         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 711             for (int i = 0; i < a.length; i += SPECIES.length()) {
 712                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 713                 av.aShiftR((int)b[i], vmask).intoArray(r, i);

 714             }
 715         }
 716 
 717         assertShiftArraysEquals(a, b, r, mask, Short64VectorTests::aShiftR_unary);
 718     }
 719 
 720 
 721     static short shiftL_unary(short a, short b) {




 722         return (short)((a << (b & 15)));
 723     }
 724 
 725     @Test(dataProvider = "shortBinaryOpProvider")
 726     static void shiftLShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 727         short[] a = fa.apply(SPECIES.length());
 728         short[] b = fb.apply(SPECIES.length());
 729         short[] r = fr.apply(SPECIES.length());
 730 
 731         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 732             for (int i = 0; i < a.length; i += SPECIES.length()) {
 733                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 734                 av.shiftL((int)b[i]).intoArray(r, i);
 735             }
 736         }
 737 
 738         assertShiftArraysEquals(a, b, r, Short64VectorTests::shiftL_unary);
 739     }
 740 
 741 
 742 
 743     @Test(dataProvider = "shortBinaryOpMaskProvider")
 744     static void shiftLShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb,
 745                                           IntFunction<boolean[]> fm) {
 746         short[] a = fa.apply(SPECIES.length());
 747         short[] b = fb.apply(SPECIES.length());
 748         short[] r = fr.apply(SPECIES.length());
 749         boolean[] mask = fm.apply(SPECIES.length());
 750         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 751 
 752         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 753             for (int i = 0; i < a.length; i += SPECIES.length()) {
 754                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 755                 av.shiftL((int)b[i], vmask).intoArray(r, i);
 756             }
 757         }
 758 
 759         assertShiftArraysEquals(a, b, r, mask, Short64VectorTests::shiftL_unary);
 760     }
 761 
 762 
 763     static short shiftR_unary(short a, short b) {




 764         return (short)(((a & 0xFFFF) >>> (b & 15)));
 765     }
 766 
 767     @Test(dataProvider = "shortBinaryOpProvider")
 768     static void shiftRShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {














































 769         short[] a = fa.apply(SPECIES.length());
 770         short[] b = fb.apply(SPECIES.length());
 771         short[] r = fr.apply(SPECIES.length());
 772 
 773         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 774             for (int i = 0; i < a.length; i += SPECIES.length()) {
 775                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 776                 av.shiftR((int)b[i]).intoArray(r, i);
 777             }
 778         }
 779 
 780         assertShiftArraysEquals(a, b, r, Short64VectorTests::shiftR_unary);
 781     }
 782 
 783 
 784 
 785     @Test(dataProvider = "shortBinaryOpMaskProvider")
 786     static void shiftRShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb,
 787                                           IntFunction<boolean[]> fm) {
 788         short[] a = fa.apply(SPECIES.length());
 789         short[] b = fb.apply(SPECIES.length());
 790         short[] r = fr.apply(SPECIES.length());
 791         boolean[] mask = fm.apply(SPECIES.length());
 792         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 793 
 794         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 795             for (int i = 0; i < a.length; i += SPECIES.length()) {
 796                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 797                 av.shiftR((int)b[i], vmask).intoArray(r, i);
 798             }
 799         }
 800 
 801         assertShiftArraysEquals(a, b, r, mask, Short64VectorTests::shiftR_unary);
 802     }
 803 
 804     static short max(short a, short b) {
 805         return (short)(Math.max(a, b));
 806     }
 807 
 808     @Test(dataProvider = "shortBinaryOpProvider")
 809     static void maxShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 810         short[] a = fa.apply(SPECIES.length());
 811         short[] b = fb.apply(SPECIES.length());
 812         short[] r = fr.apply(SPECIES.length());
 813 
 814         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 815             for (int i = 0; i < a.length; i += SPECIES.length()) {
 816                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 817                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 818                 av.max(bv).intoArray(r, i);
 819             }
 820         }
 821 


 825         return (short)(Math.min(a, b));
 826     }
 827 
 828     @Test(dataProvider = "shortBinaryOpProvider")
 829     static void minShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 830         short[] a = fa.apply(SPECIES.length());
 831         short[] b = fb.apply(SPECIES.length());
 832         short[] r = fr.apply(SPECIES.length());
 833 
 834         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 835             for (int i = 0; i < a.length; i += SPECIES.length()) {
 836                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 837                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 838                 av.min(bv).intoArray(r, i);
 839             }
 840         }
 841 
 842         assertArraysEquals(a, b, r, Short64VectorTests::min);
 843     }
 844 
 845     static short andAll(short[] a, int idx) {
 846         short res = -1;
 847         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 848             res &= a[i];
 849         }
 850 
 851         return res;
 852     }
 853 
 854     static short andAll(short[] a) {
 855         short res = -1;
 856         for (int i = 0; i < a.length; i += SPECIES.length()) {
 857             short tmp = -1;
 858             for (int j = 0; j < SPECIES.length(); j++) {
 859                 tmp &= a[i + j];
 860             }
 861             res &= tmp;
 862         }
 863 
 864         return res;
 865     }
 866 
 867 
 868     @Test(dataProvider = "shortUnaryOpProvider")
 869     static void andAllShort64VectorTests(IntFunction<short[]> fa) {
 870         short[] a = fa.apply(SPECIES.length());
 871         short[] r = fr.apply(SPECIES.length());
 872         short ra = -1;
 873 
 874         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 875             for (int i = 0; i < a.length; i += SPECIES.length()) {
 876                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 877                 r[i] = av.andAll();
 878             }
 879         }
 880 
 881         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 882             ra = -1;
 883             for (int i = 0; i < a.length; i += SPECIES.length()) {
 884                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 885                 ra &= av.andAll();
 886             }
 887         }
 888 
 889         assertReductionArraysEquals(a, r, ra, Short64VectorTests::andAll, Short64VectorTests::andAll);
 890     }
 891 
 892 
 893     static short orAll(short[] a, int idx) {
 894         short res = 0;
 895         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 896             res |= a[i];
 897         }
 898 
 899         return res;
 900     }
 901 
 902     static short orAll(short[] a) {
 903         short res = 0;
 904         for (int i = 0; i < a.length; i += SPECIES.length()) {
 905             short tmp = 0;
 906             for (int j = 0; j < SPECIES.length(); j++) {
 907                 tmp |= a[i + j];
 908             }
 909             res |= tmp;
 910         }
 911 
 912         return res;
 913     }
 914 
 915 
 916     @Test(dataProvider = "shortUnaryOpProvider")
 917     static void orAllShort64VectorTests(IntFunction<short[]> fa) {
 918         short[] a = fa.apply(SPECIES.length());
 919         short[] r = fr.apply(SPECIES.length());
 920         short ra = 0;
 921 
 922         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 923             for (int i = 0; i < a.length; i += SPECIES.length()) {
 924                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 925                 r[i] = av.orAll();
 926             }
 927         }
 928 
 929         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 930             ra = 0;
 931             for (int i = 0; i < a.length; i += SPECIES.length()) {
 932                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 933                 ra |= av.orAll();
 934             }
 935         }
 936 
 937         assertReductionArraysEquals(a, r, ra, Short64VectorTests::orAll, Short64VectorTests::orAll);
 938     }
 939 
 940 
 941     static short xorAll(short[] a, int idx) {
 942         short res = 0;
 943         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 944             res ^= a[i];
 945         }
 946 
 947         return res;
 948     }
 949 
 950     static short xorAll(short[] a) {
 951         short res = 0;
 952         for (int i = 0; i < a.length; i += SPECIES.length()) {
 953             short tmp = 0;
 954             for (int j = 0; j < SPECIES.length(); j++) {
 955                 tmp ^= a[i + j];
 956             }
 957             res ^= tmp;
 958         }
 959 
 960         return res;
 961     }
 962 
 963 
 964     @Test(dataProvider = "shortUnaryOpProvider")
 965     static void xorAllShort64VectorTests(IntFunction<short[]> fa) {
 966         short[] a = fa.apply(SPECIES.length());
 967         short[] r = fr.apply(SPECIES.length());
 968         short ra = 0;
 969 
 970         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 971             for (int i = 0; i < a.length; i += SPECIES.length()) {
 972                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 973                 r[i] = av.xorAll();
 974             }
 975         }
 976 
 977         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 978             ra = 0;
 979             for (int i = 0; i < a.length; i += SPECIES.length()) {
 980                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 981                 ra ^= av.xorAll();
 982             }
 983         }
 984 
 985         assertReductionArraysEquals(a, r, ra, Short64VectorTests::xorAll, Short64VectorTests::xorAll);
 986     }
 987 
 988     static short addAll(short[] a, int idx) {
 989         short res = 0;
 990         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 991             res += a[i];
 992         }
 993 
 994         return res;
 995     }
 996 
 997     static short addAll(short[] a) {
 998         short res = 0;
 999         for (int i = 0; i < a.length; i += SPECIES.length()) {
1000             short tmp = 0;
1001             for (int j = 0; j < SPECIES.length(); j++) {
1002                 tmp += a[i + j];
1003             }
1004             res += tmp;
1005         }
1006 
1007         return res;
1008     }
1009     @Test(dataProvider = "shortUnaryOpProvider")
1010     static void addAllShort64VectorTests(IntFunction<short[]> fa) {
1011         short[] a = fa.apply(SPECIES.length());
1012         short[] r = fr.apply(SPECIES.length());
1013         short ra = 0;
1014 
1015         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1016             for (int i = 0; i < a.length; i += SPECIES.length()) {
1017                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1018                 r[i] = av.addAll();
1019             }
1020         }
1021 
1022         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1023             ra = 0;
1024             for (int i = 0; i < a.length; i += SPECIES.length()) {
1025                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1026                 ra += av.addAll();
1027             }
1028         }
1029 
1030         assertReductionArraysEquals(a, r, ra, Short64VectorTests::addAll, Short64VectorTests::addAll);
1031     }
1032     static short mulAll(short[] a, int idx) {
1033         short res = 1;
1034         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1035             res *= a[i];
1036         }
1037 
1038         return res;
1039     }
1040 
1041     static short mulAll(short[] a) {
1042         short res = 1;
1043         for (int i = 0; i < a.length; i += SPECIES.length()) {
1044             short tmp = 1;
1045             for (int j = 0; j < SPECIES.length(); j++) {
1046                 tmp *= a[i + j];
1047             }
1048             res *= tmp;
1049         }
1050 
1051         return res;
1052     }
1053     @Test(dataProvider = "shortUnaryOpProvider")
1054     static void mulAllShort64VectorTests(IntFunction<short[]> fa) {
1055         short[] a = fa.apply(SPECIES.length());
1056         short[] r = fr.apply(SPECIES.length());
1057         short ra = 1;
1058 
1059         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1060             for (int i = 0; i < a.length; i += SPECIES.length()) {
1061                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1062                 r[i] = av.mulAll();
1063             }
1064         }
1065 
1066         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1067             ra = 1;
1068             for (int i = 0; i < a.length; i += SPECIES.length()) {
1069                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1070                 ra *= av.mulAll();
1071             }
1072         }
1073 
1074         assertReductionArraysEquals(a, r, ra, Short64VectorTests::mulAll, Short64VectorTests::mulAll);
1075     }
1076     static short minAll(short[] a, int idx) {
1077         short res = Short.MAX_VALUE;
1078         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1079             res = (short)Math.min(res, a[i]);
1080         }
1081 
1082         return res;
1083     }
1084 
1085     static short minAll(short[] a) {
1086         short res = Short.MAX_VALUE;
1087         for (int i = 0; i < a.length; i++) {
1088             res = (short)Math.min(res, a[i]);
1089         }
1090 
1091         return res;
1092     }
1093     @Test(dataProvider = "shortUnaryOpProvider")
1094     static void minAllShort64VectorTests(IntFunction<short[]> fa) {
1095         short[] a = fa.apply(SPECIES.length());
1096         short[] r = fr.apply(SPECIES.length());
1097         short ra = Short.MAX_VALUE;
1098 
1099         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1100             for (int i = 0; i < a.length; i += SPECIES.length()) {
1101                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1102                 r[i] = av.minAll();
1103             }
1104         }
1105 
1106         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1107             ra = Short.MAX_VALUE;
1108             for (int i = 0; i < a.length; i += SPECIES.length()) {
1109                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1110                 ra = (short)Math.min(ra, av.minAll());
1111             }
1112         }
1113 
1114         assertReductionArraysEquals(a, r, ra, Short64VectorTests::minAll, Short64VectorTests::minAll);
1115     }
1116     static short maxAll(short[] a, int idx) {
1117         short res = Short.MIN_VALUE;
1118         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1119             res = (short)Math.max(res, a[i]);
1120         }
1121 
1122         return res;
1123     }
1124 
1125     static short maxAll(short[] a) {
1126         short res = Short.MIN_VALUE;
1127         for (int i = 0; i < a.length; i++) {
1128             res = (short)Math.max(res, a[i]);
1129         }
1130 
1131         return res;
1132     }
1133     @Test(dataProvider = "shortUnaryOpProvider")
1134     static void maxAllShort64VectorTests(IntFunction<short[]> fa) {
1135         short[] a = fa.apply(SPECIES.length());
1136         short[] r = fr.apply(SPECIES.length());
1137         short ra = Short.MIN_VALUE;
1138 
1139         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1140             for (int i = 0; i < a.length; i += SPECIES.length()) {
1141                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1142                 r[i] = av.maxAll();
1143             }
1144         }
1145 
1146         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1147             ra = Short.MIN_VALUE;
1148             for (int i = 0; i < a.length; i += SPECIES.length()) {
1149                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1150                 ra = (short)Math.max(ra, av.maxAll());
1151             }
1152         }
1153 
1154         assertReductionArraysEquals(a, r, ra, Short64VectorTests::maxAll, Short64VectorTests::maxAll);
1155     }
1156 
1157     static boolean anyTrue(boolean[] a, int idx) {
1158         boolean res = false;
1159         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1160             res |= a[i];
1161         }
1162 
1163         return res;
1164     }
1165 
1166 
1167     @Test(dataProvider = "boolUnaryOpProvider")
1168     static void anyTrueShort64VectorTests(IntFunction<boolean[]> fm) {
1169         boolean[] mask = fm.apply(SPECIES.length());
1170         boolean[] r = fmr.apply(SPECIES.length());
1171 
1172         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1173             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1174                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);




 645         short[] r = fr.apply(SPECIES.length());
 646         boolean[] mask = fm.apply(SPECIES.length());
 647         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 648 
 649         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 650             for (int i = 0; i < a.length; i += SPECIES.length()) {
 651                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 652                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 653                 av.xor(bv, vmask).intoArray(r, i);
 654             }
 655         }
 656 
 657         assertArraysEquals(a, b, r, mask, Short64VectorTests::xor);
 658     }
 659 
 660 
 661 
 662 
 663 
 664 
 665     static short shiftLeft(short a, short b) {
 666         return (short)((a << (b & 0xF)));
 667     }
 668 
 669     @Test(dataProvider = "shortBinaryOpProvider")
 670     static void shiftLeftShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 671         short[] a = fa.apply(SPECIES.length());
 672         short[] b = fb.apply(SPECIES.length());
 673         short[] r = fr.apply(SPECIES.length());
 674 
 675         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 676             for (int i = 0; i < a.length; i += SPECIES.length()) {
 677                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 678                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 679                 av.shiftLeft(bv).intoArray(r, i);
 680             }
 681         }
 682 
 683         assertArraysEquals(a, b, r, Short64VectorTests::shiftLeft);
 684     }
 685 
 686 
 687 
 688     @Test(dataProvider = "shortBinaryOpMaskProvider")
 689     static void shiftLeftShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb,
 690                                           IntFunction<boolean[]> fm) {
 691         short[] a = fa.apply(SPECIES.length());
 692         short[] b = fb.apply(SPECIES.length());
 693         short[] r = fr.apply(SPECIES.length());
 694         boolean[] mask = fm.apply(SPECIES.length());
 695         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 696 
 697         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 698             for (int i = 0; i < a.length; i += SPECIES.length()) {
 699                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 700                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 701                 av.shiftLeft(bv, vmask).intoArray(r, i);
 702             }
 703         }
 704 
 705         assertArraysEquals(a, b, r, mask, Short64VectorTests::shiftLeft);
 706     }
 707 
 708 
 709 
 710 
 711 
 712 
 713     static short shiftRight(short a, short b) {
 714         return (short)((a >>> (b & 0xF)));
 715     }
 716 
 717     @Test(dataProvider = "shortBinaryOpProvider")
 718     static void shiftRightShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 719         short[] a = fa.apply(SPECIES.length());
 720         short[] b = fb.apply(SPECIES.length());
 721         short[] r = fr.apply(SPECIES.length());
 722 
 723         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 724             for (int i = 0; i < a.length; i += SPECIES.length()) {
 725                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 726                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 727                 av.shiftRight(bv).intoArray(r, i);
 728             }
 729         }
 730 
 731         assertArraysEquals(a, b, r, Short64VectorTests::shiftRight);
 732     }
 733 
 734 
 735 
 736     @Test(dataProvider = "shortBinaryOpMaskProvider")
 737     static void shiftRightShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb,
 738                                           IntFunction<boolean[]> fm) {
 739         short[] a = fa.apply(SPECIES.length());
 740         short[] b = fb.apply(SPECIES.length());
 741         short[] r = fr.apply(SPECIES.length());
 742         boolean[] mask = fm.apply(SPECIES.length());
 743         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 744 
 745         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 746             for (int i = 0; i < a.length; i += SPECIES.length()) {
 747                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 748                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 749                 av.shiftRight(bv, vmask).intoArray(r, i);
 750             }
 751         }
 752 
 753         assertArraysEquals(a, b, r, mask, Short64VectorTests::shiftRight);
 754     }
 755 
 756 
 757 
 758 
 759 
 760 
 761     static short shiftArithmeticRight(short a, short b) {
 762         return (short)((a >> (b & 0xF)));
 763     }
 764 
 765     @Test(dataProvider = "shortBinaryOpProvider")
 766     static void shiftArithmeticRightShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 767         short[] a = fa.apply(SPECIES.length());
 768         short[] b = fb.apply(SPECIES.length());
 769         short[] r = fr.apply(SPECIES.length());
 770 
 771         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 772             for (int i = 0; i < a.length; i += SPECIES.length()) {
 773                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 774                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 775                 av.shiftArithmeticRight(bv).intoArray(r, i);
 776             }
 777         }
 778 
 779         assertArraysEquals(a, b, r, Short64VectorTests::shiftArithmeticRight);
 780     }
 781 
 782 
 783 
 784     @Test(dataProvider = "shortBinaryOpMaskProvider")
 785     static void shiftArithmeticRightShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb,
 786                                           IntFunction<boolean[]> fm) {
 787         short[] a = fa.apply(SPECIES.length());
 788         short[] b = fb.apply(SPECIES.length());
 789         short[] r = fr.apply(SPECIES.length());
 790         boolean[] mask = fm.apply(SPECIES.length());
 791         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 792 
 793         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 794             for (int i = 0; i < a.length; i += SPECIES.length()) {
 795                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 796                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 797                 av.shiftArithmeticRight(bv, vmask).intoArray(r, i);
 798             }
 799         }
 800 
 801         assertArraysEquals(a, b, r, mask, Short64VectorTests::shiftArithmeticRight);
 802     }
 803 
 804 
 805 
 806 
 807 
 808 
 809     static short shiftLeft_unary(short a, short b) {
 810         return (short)((a << (b & 15)));
 811     }
 812 
 813     @Test(dataProvider = "shortBinaryOpProvider")
 814     static void shiftLeftShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 815         short[] a = fa.apply(SPECIES.length());
 816         short[] b = fb.apply(SPECIES.length());
 817         short[] r = fr.apply(SPECIES.length());
 818 
 819         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 820             for (int i = 0; i < a.length; i += SPECIES.length()) {
 821                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 822                 av.shiftLeft((int)b[i]).intoArray(r, i);
 823             }
 824         }
 825 
 826         assertShiftArraysEquals(a, b, r, Short64VectorTests::shiftLeft_unary);
 827     }
 828 
 829 
 830 
 831     @Test(dataProvider = "shortBinaryOpMaskProvider")
 832     static void shiftLeftShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb,
 833                                           IntFunction<boolean[]> fm) {
 834         short[] a = fa.apply(SPECIES.length());
 835         short[] b = fb.apply(SPECIES.length());
 836         short[] r = fr.apply(SPECIES.length());
 837         boolean[] mask = fm.apply(SPECIES.length());
 838         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 839 
 840         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 841             for (int i = 0; i < a.length; i += SPECIES.length()) {
 842                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 843                 av.shiftLeft((int)b[i], vmask).intoArray(r, i);
 844             }
 845         }
 846 
 847         assertShiftArraysEquals(a, b, r, mask, Short64VectorTests::shiftLeft_unary);
 848     }
 849 
 850 
 851 
 852 
 853 
 854 
 855     static short shiftRight_unary(short a, short b) {
 856         return (short)(((a & 0xFFFF) >>> (b & 15)));
 857     }
 858 
 859     @Test(dataProvider = "shortBinaryOpProvider")
 860     static void shiftRightShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 861         short[] a = fa.apply(SPECIES.length());
 862         short[] b = fb.apply(SPECIES.length());
 863         short[] r = fr.apply(SPECIES.length());
 864 
 865         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 866             for (int i = 0; i < a.length; i += SPECIES.length()) {
 867                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 868                 av.shiftRight((int)b[i]).intoArray(r, i);
 869             }
 870         }
 871 
 872         assertShiftArraysEquals(a, b, r, Short64VectorTests::shiftRight_unary);
 873     }
 874 
 875 
 876 
 877     @Test(dataProvider = "shortBinaryOpMaskProvider")
 878     static void shiftRightShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb,
 879                                           IntFunction<boolean[]> fm) {
 880         short[] a = fa.apply(SPECIES.length());
 881         short[] b = fb.apply(SPECIES.length());
 882         short[] r = fr.apply(SPECIES.length());
 883         boolean[] mask = fm.apply(SPECIES.length());
 884         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 885 
 886         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 887             for (int i = 0; i < a.length; i += SPECIES.length()) {
 888                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 889                 av.shiftRight((int)b[i], vmask).intoArray(r, i);
 890             }
 891         }
 892 
 893         assertShiftArraysEquals(a, b, r, mask, Short64VectorTests::shiftRight_unary);
 894     }
 895 
 896 
 897 
 898 
 899 
 900 
 901     static short shiftArithmeticRight_unary(short a, short b) {
 902         return (short)((a >> (b & 15)));
 903     }
 904 
 905     @Test(dataProvider = "shortBinaryOpProvider")
 906     static void shiftArithmeticRightShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 907         short[] a = fa.apply(SPECIES.length());
 908         short[] b = fb.apply(SPECIES.length());
 909         short[] r = fr.apply(SPECIES.length());
 910 
 911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 912             for (int i = 0; i < a.length; i += SPECIES.length()) {
 913                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 914                 av.shiftArithmeticRight((int)b[i]).intoArray(r, i);
 915             }
 916         }
 917 
 918         assertShiftArraysEquals(a, b, r, Short64VectorTests::shiftArithmeticRight_unary);
 919     }
 920 
 921 
 922 
 923     @Test(dataProvider = "shortBinaryOpMaskProvider")
 924     static void shiftArithmeticRightShort64VectorTestsShift(IntFunction<short[]> fa, IntFunction<short[]> fb,
 925                                           IntFunction<boolean[]> fm) {
 926         short[] a = fa.apply(SPECIES.length());
 927         short[] b = fb.apply(SPECIES.length());
 928         short[] r = fr.apply(SPECIES.length());
 929         boolean[] mask = fm.apply(SPECIES.length());
 930         VectorMask<Short> vmask = VectorMask.fromValues(SPECIES, mask);
 931 
 932         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 933             for (int i = 0; i < a.length; i += SPECIES.length()) {
 934                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 935                 av.shiftArithmeticRight((int)b[i], vmask).intoArray(r, i);
 936             }
 937         }
 938 
 939         assertShiftArraysEquals(a, b, r, mask, Short64VectorTests::shiftArithmeticRight_unary);
 940     }
 941 
 942     static short max(short a, short b) {
 943         return (short)(Math.max(a, b));
 944     }
 945 
 946     @Test(dataProvider = "shortBinaryOpProvider")
 947     static void maxShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 948         short[] a = fa.apply(SPECIES.length());
 949         short[] b = fb.apply(SPECIES.length());
 950         short[] r = fr.apply(SPECIES.length());
 951 
 952         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 953             for (int i = 0; i < a.length; i += SPECIES.length()) {
 954                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 955                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 956                 av.max(bv).intoArray(r, i);
 957             }
 958         }
 959 


 963         return (short)(Math.min(a, b));
 964     }
 965 
 966     @Test(dataProvider = "shortBinaryOpProvider")
 967     static void minShort64VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
 968         short[] a = fa.apply(SPECIES.length());
 969         short[] b = fb.apply(SPECIES.length());
 970         short[] r = fr.apply(SPECIES.length());
 971 
 972         for (int ic = 0; ic < INVOC_COUNT; ic++) {
 973             for (int i = 0; i < a.length; i += SPECIES.length()) {
 974                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
 975                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
 976                 av.min(bv).intoArray(r, i);
 977             }
 978         }
 979 
 980         assertArraysEquals(a, b, r, Short64VectorTests::min);
 981     }
 982 
 983     static short andLanes(short[] a, int idx) {
 984         short res = -1;
 985         for (int i = idx; i < (idx + SPECIES.length()); i++) {
 986             res &= a[i];
 987         }
 988 
 989         return res;
 990     }
 991 
 992     static short andLanes(short[] a) {
 993         short res = -1;
 994         for (int i = 0; i < a.length; i += SPECIES.length()) {
 995             short tmp = -1;
 996             for (int j = 0; j < SPECIES.length(); j++) {
 997                 tmp &= a[i + j];
 998             }
 999             res &= tmp;
1000         }
1001 
1002         return res;
1003     }
1004 
1005 
1006     @Test(dataProvider = "shortUnaryOpProvider")
1007     static void andLanesShort64VectorTests(IntFunction<short[]> fa) {
1008         short[] a = fa.apply(SPECIES.length());
1009         short[] r = fr.apply(SPECIES.length());
1010         short ra = -1;
1011 
1012         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1013             for (int i = 0; i < a.length; i += SPECIES.length()) {
1014                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1015                 r[i] = av.andLanes();
1016             }
1017         }
1018 
1019         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1020             ra = -1;
1021             for (int i = 0; i < a.length; i += SPECIES.length()) {
1022                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1023                 ra &= av.andLanes();
1024             }
1025         }
1026 
1027         assertReductionArraysEquals(a, r, ra, Short64VectorTests::andLanes, Short64VectorTests::andLanes);
1028     }
1029 
1030 
1031     static short orLanes(short[] a, int idx) {
1032         short res = 0;
1033         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1034             res |= a[i];
1035         }
1036 
1037         return res;
1038     }
1039 
1040     static short orLanes(short[] a) {
1041         short res = 0;
1042         for (int i = 0; i < a.length; i += SPECIES.length()) {
1043             short tmp = 0;
1044             for (int j = 0; j < SPECIES.length(); j++) {
1045                 tmp |= a[i + j];
1046             }
1047             res |= tmp;
1048         }
1049 
1050         return res;
1051     }
1052 
1053 
1054     @Test(dataProvider = "shortUnaryOpProvider")
1055     static void orLanesShort64VectorTests(IntFunction<short[]> fa) {
1056         short[] a = fa.apply(SPECIES.length());
1057         short[] r = fr.apply(SPECIES.length());
1058         short ra = 0;
1059 
1060         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1061             for (int i = 0; i < a.length; i += SPECIES.length()) {
1062                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1063                 r[i] = av.orLanes();
1064             }
1065         }
1066 
1067         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1068             ra = 0;
1069             for (int i = 0; i < a.length; i += SPECIES.length()) {
1070                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1071                 ra |= av.orLanes();
1072             }
1073         }
1074 
1075         assertReductionArraysEquals(a, r, ra, Short64VectorTests::orLanes, Short64VectorTests::orLanes);
1076     }
1077 
1078 
1079     static short xorLanes(short[] a, int idx) {
1080         short res = 0;
1081         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1082             res ^= a[i];
1083         }
1084 
1085         return res;
1086     }
1087 
1088     static short xorLanes(short[] a) {
1089         short res = 0;
1090         for (int i = 0; i < a.length; i += SPECIES.length()) {
1091             short tmp = 0;
1092             for (int j = 0; j < SPECIES.length(); j++) {
1093                 tmp ^= a[i + j];
1094             }
1095             res ^= tmp;
1096         }
1097 
1098         return res;
1099     }
1100 
1101 
1102     @Test(dataProvider = "shortUnaryOpProvider")
1103     static void xorLanesShort64VectorTests(IntFunction<short[]> fa) {
1104         short[] a = fa.apply(SPECIES.length());
1105         short[] r = fr.apply(SPECIES.length());
1106         short ra = 0;
1107 
1108         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1109             for (int i = 0; i < a.length; i += SPECIES.length()) {
1110                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1111                 r[i] = av.xorLanes();
1112             }
1113         }
1114 
1115         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1116             ra = 0;
1117             for (int i = 0; i < a.length; i += SPECIES.length()) {
1118                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1119                 ra ^= av.xorLanes();
1120             }
1121         }
1122 
1123         assertReductionArraysEquals(a, r, ra, Short64VectorTests::xorLanes, Short64VectorTests::xorLanes);
1124     }
1125 
1126     static short addLanes(short[] a, int idx) {
1127         short res = 0;
1128         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1129             res += a[i];
1130         }
1131 
1132         return res;
1133     }
1134 
1135     static short addLanes(short[] a) {
1136         short res = 0;
1137         for (int i = 0; i < a.length; i += SPECIES.length()) {
1138             short tmp = 0;
1139             for (int j = 0; j < SPECIES.length(); j++) {
1140                 tmp += a[i + j];
1141             }
1142             res += tmp;
1143         }
1144 
1145         return res;
1146     }
1147     @Test(dataProvider = "shortUnaryOpProvider")
1148     static void addLanesShort64VectorTests(IntFunction<short[]> fa) {
1149         short[] a = fa.apply(SPECIES.length());
1150         short[] r = fr.apply(SPECIES.length());
1151         short ra = 0;
1152 
1153         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1154             for (int i = 0; i < a.length; i += SPECIES.length()) {
1155                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1156                 r[i] = av.addLanes();
1157             }
1158         }
1159 
1160         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1161             ra = 0;
1162             for (int i = 0; i < a.length; i += SPECIES.length()) {
1163                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1164                 ra += av.addLanes();
1165             }
1166         }
1167 
1168         assertReductionArraysEquals(a, r, ra, Short64VectorTests::addLanes, Short64VectorTests::addLanes);
1169     }
1170     static short mulLanes(short[] a, int idx) {
1171         short res = 1;
1172         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1173             res *= a[i];
1174         }
1175 
1176         return res;
1177     }
1178 
1179     static short mulLanes(short[] a) {
1180         short res = 1;
1181         for (int i = 0; i < a.length; i += SPECIES.length()) {
1182             short tmp = 1;
1183             for (int j = 0; j < SPECIES.length(); j++) {
1184                 tmp *= a[i + j];
1185             }
1186             res *= tmp;
1187         }
1188 
1189         return res;
1190     }
1191     @Test(dataProvider = "shortUnaryOpProvider")
1192     static void mulLanesShort64VectorTests(IntFunction<short[]> fa) {
1193         short[] a = fa.apply(SPECIES.length());
1194         short[] r = fr.apply(SPECIES.length());
1195         short ra = 1;
1196 
1197         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1198             for (int i = 0; i < a.length; i += SPECIES.length()) {
1199                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1200                 r[i] = av.mulLanes();
1201             }
1202         }
1203 
1204         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1205             ra = 1;
1206             for (int i = 0; i < a.length; i += SPECIES.length()) {
1207                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1208                 ra *= av.mulLanes();
1209             }
1210         }
1211 
1212         assertReductionArraysEquals(a, r, ra, Short64VectorTests::mulLanes, Short64VectorTests::mulLanes);
1213     }
1214     static short minLanes(short[] a, int idx) {
1215         short res = Short.MAX_VALUE;
1216         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1217             res = (short)Math.min(res, a[i]);
1218         }
1219 
1220         return res;
1221     }
1222 
1223     static short minLanes(short[] a) {
1224         short res = Short.MAX_VALUE;
1225         for (int i = 0; i < a.length; i++) {
1226             res = (short)Math.min(res, a[i]);
1227         }
1228 
1229         return res;
1230     }
1231     @Test(dataProvider = "shortUnaryOpProvider")
1232     static void minLanesShort64VectorTests(IntFunction<short[]> fa) {
1233         short[] a = fa.apply(SPECIES.length());
1234         short[] r = fr.apply(SPECIES.length());
1235         short ra = Short.MAX_VALUE;
1236 
1237         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1238             for (int i = 0; i < a.length; i += SPECIES.length()) {
1239                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1240                 r[i] = av.minLanes();
1241             }
1242         }
1243 
1244         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1245             ra = Short.MAX_VALUE;
1246             for (int i = 0; i < a.length; i += SPECIES.length()) {
1247                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1248                 ra = (short)Math.min(ra, av.minLanes());
1249             }
1250         }
1251 
1252         assertReductionArraysEquals(a, r, ra, Short64VectorTests::minLanes, Short64VectorTests::minLanes);
1253     }
1254     static short maxLanes(short[] a, int idx) {
1255         short res = Short.MIN_VALUE;
1256         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1257             res = (short)Math.max(res, a[i]);
1258         }
1259 
1260         return res;
1261     }
1262 
1263     static short maxLanes(short[] a) {
1264         short res = Short.MIN_VALUE;
1265         for (int i = 0; i < a.length; i++) {
1266             res = (short)Math.max(res, a[i]);
1267         }
1268 
1269         return res;
1270     }
1271     @Test(dataProvider = "shortUnaryOpProvider")
1272     static void maxLanesShort64VectorTests(IntFunction<short[]> fa) {
1273         short[] a = fa.apply(SPECIES.length());
1274         short[] r = fr.apply(SPECIES.length());
1275         short ra = Short.MIN_VALUE;
1276 
1277         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1278             for (int i = 0; i < a.length; i += SPECIES.length()) {
1279                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1280                 r[i] = av.maxLanes();
1281             }
1282         }
1283 
1284         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1285             ra = Short.MIN_VALUE;
1286             for (int i = 0; i < a.length; i += SPECIES.length()) {
1287                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1288                 ra = (short)Math.max(ra, av.maxLanes());
1289             }
1290         }
1291 
1292         assertReductionArraysEquals(a, r, ra, Short64VectorTests::maxLanes, Short64VectorTests::maxLanes);
1293     }
1294 
1295     static boolean anyTrue(boolean[] a, int idx) {
1296         boolean res = false;
1297         for (int i = idx; i < (idx + SPECIES.length()); i++) {
1298             res |= a[i];
1299         }
1300 
1301         return res;
1302     }
1303 
1304 
1305     @Test(dataProvider = "boolUnaryOpProvider")
1306     static void anyTrueShort64VectorTests(IntFunction<boolean[]> fm) {
1307         boolean[] mask = fm.apply(SPECIES.length());
1308         boolean[] r = fmr.apply(SPECIES.length());
1309 
1310         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1311             for (int i = 0; i < mask.length; i += SPECIES.length()) {
1312                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);


< prev index next >