| 1 | #include <stdio.h> |
| 2 | #include <string.h> |
| 3 | |
| 4 | int main() |
| 5 | { |
| 6 | static const int cmp[4][4] = { |
| 7 | { 110, 134, 158, 182 }, |
| 8 | { 390, 478, 566, 654 }, |
| 9 | { 670, 822, 974, 1126 }, |
| 10 | { 950, 1166, 1382, 1598 } |
| 11 | }; |
| 12 | int dst[4][4]; |
| 13 | int *tmp = &dst[0][0]; |
| 14 | |
| 15 | asm volatile( |
| 16 | ".arch armv8-r+sme\n\t" |
| 17 | "smstart\n\t" |
| 18 | "index z0.b, #0, #1\n\t" |
| 19 | "movprfx z1, z0\n\t" |
| 20 | "add z1.b, z1.b, #16\n\t" |
| 21 | "ptrue p0.b\n\t" |
| 22 | "smopa za0.s, p0/m, p0/m, z0.b, z1.b\n\t" |
| 23 | "ptrue p0.s, vl4\n\t" |
| 24 | "mov w12, #0\n\t" |
| 25 | "st1w { za0h.s[w12, #0] }, p0, [%0]\n\t" |
| 26 | "add %0, %0, #16\n\t" |
| 27 | "st1w { za0h.s[w12, #1] }, p0, [%0]\n\t" |
| 28 | "add %0, %0, #16\n\t" |
| 29 | "st1w { za0h.s[w12, #2] }, p0, [%0]\n\t" |
| 30 | "add %0, %0, #16\n\t" |
| 31 | "st1w { za0h.s[w12, #3] }, p0, [%0]\n\t" |
| 32 | "smstop" |
| 33 | : "+r"(tmp) : : "memory"); |
| 34 | |
| 35 | if (memcmp(cmp, dst, sizeof(dst)) == 0) { |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | /* See above for correct results. */ |
| 40 | for (int i = 0; i < 4; ++i) { |
| 41 | for (int j = 0; j < 4; ++j) { |
| 42 | printf("%6d", dst[i][j]); |
| 43 | } |
| 44 | printf("\n"); |
| 45 | } |
| 46 | return 1; |
| 47 | } |