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