881
882 if (n <= 8) {
883 if (n == 8) {
891 }
892 if (n >= 7) {
899 }
900 if (n >= 6) {
906 }
907 if (n >= 5) {
912 }
913 if (n >= 4) {
917 }
918 if (n >= 3) {
921 }
922 if (n >= 2) {
924 }
925 return;
926 }
927
928 if (!(n & (n - 1))) {
929 int32_sort_2power(x,n,0);
930 return;
931 }
932
933 q = 8;
934 while (q < n - q) q += q;
935
936
937 if (q <= 128) {
939 for (
i = q>>3;
i < q>>2;++
i) y[
i] = _mm256_set1_epi32(0x7fffffff);
941 int32_sort_2power((
int32 *) y,2*q,0);
943 return;
944 }
945
946 int32_sort_2power(x,q,1);
948
949 while (q >= 64) {
950 q >>= 2;
951 j = int32_threestages(x,n,q);
952 minmax_vector(x +
j,x +
j + 4*q,n - 4*q -
j);
954 for (
i =
j;
i <
j + q;
i += 8) {
967 }
969 }
970 minmax_vector(x +
j,x +
j + 2*q,n - 2*q -
j);
972 for (
i =
j;
i <
j + q;
i += 8) {
978 }
980 }
981 minmax_vector(x +
j,x +
j + q,n - q -
j);
982 q >>= 1;
983 }
984 if (q == 32) {
986 for (;
j + 64 <=
n;
j += 64) {
1007 int32x8 a0 = _mm256_permute2x128_si256(x0,x1,0x20);
1008 int32x8 a1 = _mm256_permute2x128_si256(x0,x1,0x31);
1009 int32x8 a2 = _mm256_permute2x128_si256(x2,x3,0x20);
1010 int32x8 a3 = _mm256_permute2x128_si256(x2,x3,0x31);
1011 int32x8 a4 = _mm256_permute2x128_si256(x4,x5,0x20);
1012 int32x8 a5 = _mm256_permute2x128_si256(x4,x5,0x31);
1013 int32x8 a6 = _mm256_permute2x128_si256(x6,x7,0x20);
1014 int32x8 a7 = _mm256_permute2x128_si256(x6,x7,0x31);
1019 int32x8 b0 = _mm256_permute2x128_si256(a0,
a1,0x20);
1020 int32x8 b1 = _mm256_permute2x128_si256(a0,
a1,0x31);
1021 int32x8 b2 = _mm256_permute2x128_si256(a2,
a3,0x20);
1022 int32x8 b3 = _mm256_permute2x128_si256(a2,
a3,0x31);
1023 int32x8 b4 = _mm256_permute2x128_si256(a4,a5,0x20);
1024 int32x8 b5 = _mm256_permute2x128_si256(a4,a5,0x31);
1025 int32x8 b6 = _mm256_permute2x128_si256(a6,a7,0x20);
1026 int32x8 b7 = _mm256_permute2x128_si256(a6,a7,0x31);
1027 int32x8 c0 = _mm256_unpacklo_epi64(b0,b1);
1028 int32x8 c1 = _mm256_unpackhi_epi64(b0,b1);
1029 int32x8 c2 = _mm256_unpacklo_epi64(b2,b3);
1030 int32x8 c3 = _mm256_unpackhi_epi64(b2,b3);
1032 int32x8 c5 = _mm256_unpackhi_epi64(
b4,b5);
1033 int32x8 c6 = _mm256_unpacklo_epi64(b6,b7);
1034 int32x8 c7 = _mm256_unpackhi_epi64(b6,b7);
1039 int32x8 d0 = _mm256_unpacklo_epi32(c0,c1);
1040 int32x8 d1 = _mm256_unpackhi_epi32(c0,c1);
1041 int32x8 d2 = _mm256_unpacklo_epi32(c2,c3);
1042 int32x8 d3 = _mm256_unpackhi_epi32(c2,c3);
1043 int32x8 d4 = _mm256_unpacklo_epi32(
c4,c5);
1044 int32x8 d5 = _mm256_unpackhi_epi32(
c4,c5);
1045 int32x8 d6 = _mm256_unpacklo_epi32(
c6,c7);
1046 int32x8 d7 = _mm256_unpackhi_epi32(
c6,c7);
1047 int32x8 e0 = _mm256_unpacklo_epi64(d0,d1);
1048 int32x8 e1 = _mm256_unpackhi_epi64(d0,d1);
1049 int32x8 e2 = _mm256_unpacklo_epi64(d2,d3);
1050 int32x8 e3 = _mm256_unpackhi_epi64(d2,d3);
1051 int32x8 e4 = _mm256_unpacklo_epi64(d4,d5);
1052 int32x8 e5 = _mm256_unpackhi_epi64(d4,d5);
1053 int32x8 e6 = _mm256_unpacklo_epi64(d6,d7);
1054 int32x8 e7 = _mm256_unpackhi_epi64(d6,d7);
1059 int32x8 f0 = _mm256_unpacklo_epi32(e0,e1);
1060 int32x8 f1 = _mm256_unpackhi_epi32(e0,e1);
1061 int32x8 f2 = _mm256_unpacklo_epi32(e2,e3);
1062 int32x8 f3 = _mm256_unpackhi_epi32(e2,e3);
1063 int32x8 f4 = _mm256_unpacklo_epi32(e4,e5);
1064 int32x8 f5 = _mm256_unpackhi_epi32(e4,e5);
1065 int32x8 f6 = _mm256_unpacklo_epi32(e6,e7);
1066 int32x8 f7 = _mm256_unpackhi_epi32(e6,e7);
1075 }
1076 minmax_vector(x +
j,x +
j + 32,n - 32 -
j);
1077 goto continue16;
1078 }
1079 if (q == 16) {
1081 continue16:
1082 for (;
j + 32 <=
n;
j += 32) {
1091 int32x8 a0 = _mm256_permute2x128_si256(x0,x1,0x20);
1092 int32x8 a1 = _mm256_permute2x128_si256(x0,x1,0x31);
1093 int32x8 a2 = _mm256_permute2x128_si256(x2,x3,0x20);
1094 int32x8 a3 = _mm256_permute2x128_si256(x2,x3,0x31);
1097 int32x8 b0 = _mm256_permute2x128_si256(a0,
a1,0x20);
1098 int32x8 b1 = _mm256_permute2x128_si256(a0,
a1,0x31);
1099 int32x8 b2 = _mm256_permute2x128_si256(a2,
a3,0x20);
1100 int32x8 b3 = _mm256_permute2x128_si256(a2,
a3,0x31);
1101 int32x8 c0 = _mm256_unpacklo_epi64(b0,b1);
1102 int32x8 c1 = _mm256_unpackhi_epi64(b0,b1);
1103 int32x8 c2 = _mm256_unpacklo_epi64(b2,b3);
1104 int32x8 c3 = _mm256_unpackhi_epi64(b2,b3);
1107 int32x8 d0 = _mm256_unpacklo_epi32(c0,c1);
1108 int32x8 d1 = _mm256_unpackhi_epi32(c0,c1);
1109 int32x8 d2 = _mm256_unpacklo_epi32(c2,c3);
1110 int32x8 d3 = _mm256_unpackhi_epi32(c2,c3);
1111 int32x8 e0 = _mm256_unpacklo_epi64(d0,d1);
1112 int32x8 e1 = _mm256_unpackhi_epi64(d0,d1);
1113 int32x8 e2 = _mm256_unpacklo_epi64(d2,d3);
1114 int32x8 e3 = _mm256_unpackhi_epi64(d2,d3);
1117 int32x8 f0 = _mm256_unpacklo_epi32(e0,e1);
1118 int32x8 f1 = _mm256_unpackhi_epi32(e0,e1);
1119 int32x8 f2 = _mm256_unpacklo_epi32(e2,e3);
1120 int32x8 f3 = _mm256_unpackhi_epi32(e2,e3);
1125 }
1126 minmax_vector(x +
j,x +
j + 16,n - 16 -
j);
1127 goto continue8;
1128 }
1129
1131 continue8:
1132 for (;
j + 16 <=
n;
j += 16) {
1138 int32x8 a0 = _mm256_permute2x128_si256(x0,x1,0x20);
1139 int32x8 a1 = _mm256_permute2x128_si256(x0,x1,0x31);
1141 int32x8 b0 = _mm256_permute2x128_si256(a0,
a1,0x20);
1142 int32x8 b1 = _mm256_permute2x128_si256(a0,
a1,0x31);
1143 int32x8 c0 = _mm256_unpacklo_epi64(b0,b1);
1144 int32x8 c1 = _mm256_unpackhi_epi64(b0,b1);
1146 int32x8 d0 = _mm256_unpacklo_epi32(c0,c1);
1147 int32x8 d1 = _mm256_unpackhi_epi32(c0,c1);
1148 int32x8 e0 = _mm256_unpacklo_epi64(d0,d1);
1149 int32x8 e1 = _mm256_unpackhi_epi64(d0,d1);
1151 int32x8 f0 = _mm256_unpacklo_epi32(e0,e1);
1152 int32x8 f1 = _mm256_unpackhi_epi32(e0,e1);
1155 }
1156 minmax_vector(x +
j,x +
j + 8,n - 8 -
j);
1171 }
1172 minmax_vector(x +
j,x +
j + 4,n - 4 -
j);
1179 }
1184}
function j_invariant(a1, a3, a2, a4, a6) b2 b4