aboutsummaryrefslogtreecommitdiff
path: root/src/core/NEON/kernels/arm_gemm/kernels/sve_hybrid_u8qa_mmla_4x4VL/generic.cpp
blob: 69894bec410a0475d14439365bd565f77daf79c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
/*
 * Copyright (c) 2021, 2023 Arm Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
#ifdef ARM_COMPUTE_ENABLE_SVE

#include "arm_gemm.hpp"
#include "../../utils.hpp"

#include <cassert>
#include <cstdint>

namespace arm_gemm {

void sve_hybrid_u8qa_mmla_4x4VL (
    unsigned int num_strings, const unsigned int *string_lengths, IndirectInputArg<uint8_t> A_arg,
    size_t M, size_t N, const uint8_t *B_ptr, IndirectOutputArg<uint8_t> output_arg,
    const Requantize32 *qp, const int32_t *col_bias, unsigned int
)
{
    struct KernelArgs {
        unsigned int num_strings = {};
        const unsigned int *string_lengths = {};
        size_t N = {};
        const uint8_t *B_ptr = {};
        size_t output_offset = {};
        size_t input_initial_col = {};
        size_t input_offset = {};
    } ka;

    unsigned long flags=0;
    void *output_ptr;
    void *input_ptr;

    if (output_arg.is_indirect) {
        output_ptr=(void *)(output_arg.indirect.ptr);
        ka.output_offset=output_arg.indirect.offset;
        flags |= 0x4;
    } else {
        output_ptr=(void *)(output_arg.direct.base);
        ka.output_offset=output_arg.direct.stride;
    }

    if (A_arg.is_indirect) {
        input_ptr=(void *)(A_arg.indirect.ptr);
        ka.input_offset=A_arg.indirect.start_row;
        ka.input_initial_col=A_arg.indirect.start_col;
        flags |= 0x8;
    } else {
        assert(num_strings==1);
        input_ptr=(void *)(A_arg.direct.base);
        ka.input_offset=A_arg.direct.stride;
    }
    ka.num_strings = num_strings;
    ka.string_lengths = string_lengths;
    ka.N = N;
    ka.B_ptr = B_ptr;
    if (qp->c_offset > qp->minval) {
        flags |= 0x20;
    }
    __asm__ __volatile__(
      "ptrue p2.b\n"
      "1:"  // Row loop
      "cmp %x[M], #0x4\n"
      "bge 43f\n"
      "cmp %x[M], #0x2\n"
      "bgt 29f\n"
      "beq 15f\n"
      "mov x10, %x[col_bias]\n"
      "mov z11.s, #0x0\n"
      "mov z15.b, #0x1\n"
      "bic %x[flags], %x[flags], #0x80000000\n"
      "ldr x9, [%x[args_ptr], %[offsetof_N]]\n"
      "ldr x28, [%x[args_ptr], %[offsetof_B_ptr]]\n"
      "mov x27, %x[output_ptr]\n"
      "2:"  // Height 1: Column loop
      "mov x20, #0x0\n"
      "whilelt p1.b, x20, x9\n"
      "mov z16.s, #0x0\n"
      "mov z17.s, #0x0\n"
      "mov z18.s, #0x0\n"
      "mov z19.s, #0x0\n"
      "mov z20.s, #0x0\n"
      "mov z21.s, #0x0\n"
      "mov z22.s, #0x0\n"
      "mov z23.s, #0x0\n"
      "3:"  // Height 1: setup done
      "mov x26, #0x0\n"
      "4:"  // Height 1: String loop
      "ldr x20, [%x[args_ptr], %[offsetof_string_lengths]]\n"
      "ldr w25, [x20, x26, LSL #0x2]\n"
      "ldr x21, [%x[args_ptr], %[offsetof_input_offset]]\n"
      "tbz %x[flags], #3, 5f\n"
      "ldr x20, [%x[input_ptr], x26, LSL #0x3]\n"
      "add x20, x20, x21, LSL #3\n"
      "ldr x24, [x20, #0x0]\n"
      "cbnz x26, 6f\n"
      "ldr x20, [%x[args_ptr], %[offsetof_input_initial_col]]\n"
      "add x24, x24, x20\n"
      "b 6f\n"
      "5:"  // Height 1: setup direct input
      "mov x24, %x[input_ptr]\n"
      "6:"  // Height 1: input setup done
      "cmp x25, #0x10\n"
      "ble 9f\n"
      "7:"  // Height 1: Multiply loop: Main loop head
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "trn1 z0.d, z1.d, z26.d\n"
      "ld1b { z24.b }, p2/Z, [x28]\n"
      ".inst 0x45d89810  // ummla z16.s, z0.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #1, MUL VL]\n"
      "trn2 z1.d, z1.d, z26.d\n"
      "ld1b { z24.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z26.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45d99814  // ummla z20.s, z0.b, z25.b\n"
      ".inst 0x45d89811  // ummla z17.s, z0.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45da9815  // ummla z21.s, z0.b, z26.b\n"
      ".inst 0x45d99812  // ummla z18.s, z0.b, z25.b\n"
      "ld1b { z26.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z25.b }, p2/Z, [x28, #7, MUL VL]\n"
      "addvl x28, x28, #16\n"
      ".inst 0x45d89816  // ummla z22.s, z0.b, z24.b\n"
      "ld1b { z24.b }, p2/Z, [x28, #-8, MUL VL]\n"
      ".inst 0x45da9813  // ummla z19.s, z0.b, z26.b\n"
      ".inst 0x45d99817  // ummla z23.s, z0.b, z25.b\n"
      "ld1b { z26.b }, p2/Z, [x28, #-7, MUL VL]\n"
      ".inst 0x45d89830  // ummla z16.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #-6, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #-5, MUL VL]\n"
      ".inst 0x45da9834  // ummla z20.s, z1.b, z26.b\n"
      "ld1b { z27.b }, p2/Z, [x28, #-4, MUL VL]\n"
      "ld1b { z26.b }, p2/Z, [x28, #-3, MUL VL]\n"
      ".inst 0x45d99831  // ummla z17.s, z1.b, z25.b\n"
      ".inst 0x45d89835  // ummla z21.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #-2, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #-1, MUL VL]\n"
      ".inst 0x45db9832  // ummla z18.s, z1.b, z27.b\n"
      ".inst 0x45da9836  // ummla z22.s, z1.b, z26.b\n"
      ".inst 0x45d99833  // ummla z19.s, z1.b, z25.b\n"
      ".inst 0x45d89837  // ummla z23.s, z1.b, z24.b\n"
      "add x24, x24, #0x10\n"
      "tbnz %x[flags], #31, 8f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "8:"  // Height 1: Multiply loop: unique 1: skip row sum
      "sub x25, x25, #0x10\n"
      "cmp x25, #0x10\n"
      "bgt 7b\n"
      "9:"  // Height 1: Multiply loop: Single iteration only
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "trn1 z0.d, z1.d, z27.d\n"
      "ld1b { z24.b }, p2/Z, [x28]\n"
      ".inst 0x45d89810  // ummla z16.s, z0.b, z24.b\n"
      "ld1b { z26.b }, p2/Z, [x28, #1, MUL VL]\n"
      "subs x25, x25, #0x8\n"
      "ld1b { z25.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #3, MUL VL]\n"
      "trn2 z1.d, z1.d, z27.d\n"
      ".inst 0x45da9814  // ummla z20.s, z0.b, z26.b\n"
      "ld1b { z27.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z26.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45d99811  // ummla z17.s, z0.b, z25.b\n"
      ".inst 0x45d89815  // ummla z21.s, z0.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45db9812  // ummla z18.s, z0.b, z27.b\n"
      ".inst 0x45da9816  // ummla z22.s, z0.b, z26.b\n"
      ".inst 0x45d99813  // ummla z19.s, z0.b, z25.b\n"
      ".inst 0x45d89817  // ummla z23.s, z0.b, z24.b\n"
      "addvl x28, x28, #8\n"
      "ble 10f\n"
      "ld1b { z24.b }, p2/Z, [x28]\n"
      ".inst 0x45d89830  // ummla z16.s, z1.b, z24.b\n"
      "ld1b { z24.b }, p2/Z, [x28, #1, MUL VL]\n"
      ".inst 0x45d89834  // ummla z20.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45d99831  // ummla z17.s, z1.b, z25.b\n"
      ".inst 0x45d89835  // ummla z21.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45d99832  // ummla z18.s, z1.b, z25.b\n"
      ".inst 0x45d89836  // ummla z22.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45d99833  // ummla z19.s, z1.b, z25.b\n"
      ".inst 0x45d89837  // ummla z23.s, z1.b, z24.b\n"
      "addvl x28, x28, #8\n"
      "10:"  // Height 1: Multiply loop: multiply skip
      "tbnz %x[flags], #31, 11f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "11:"  // Height 1: Multiply loop: unique 2: skip row sum
      "ldr w20, [%x[args_ptr], %[offsetof_num_strings]]\n"
      "add x26, x26, #0x1\n"
      "cmp x26, x20\n"
      "bne 4b\n"
      "uzp1 z16.d, z16.d, z20.d\n"
      "uzp1 z17.d, z17.d, z21.d\n"
      "uzp1 z18.d, z18.d, z22.d\n"
      "uzp1 z19.d, z19.d, z23.d\n"
      "mov z23.d, z16.d\n"
      "tbnz %x[flags], #31, 12f\n"
      "add x20, %x[qp], %[b_offset]\n"
      "ld1rw { z16.s }, p2/Z, [x20]\n"
      ".inst 0x4491a96b  // addp z11.s, p2/m, z11.s, z11.s\n"
      "neg z16.s, p2/M, z16.s\n"
      "mov z11.s, z11.s[0]\n"
      "mul z11.s, p2/M, z11.s, z16.s\n"
      "12:"  // Height 1: skip row sum fixup
      "add z23.s, z23.s, z11.s\n"
      "add z17.s, z17.s, z11.s\n"
      "ld1w { z22.s }, p2/Z, [x10]\n"
      "ld1w { z21.s }, p2/Z, [x10, #1, MUL VL]\n"
      "add z18.s, z18.s, z11.s\n"
      "add z19.s, z19.s, z11.s\n"
      "ld1w { z20.s }, p2/Z, [x10, #2, MUL VL]\n"
      "ld1w { z16.s }, p2/Z, [x10, #3, MUL VL]\n"
      "add x20, %x[qp], %[per_layer_mul]\n"
      "orr %x[flags], %x[flags], #0x80000000\n"
      "add z23.s, z23.s, z22.s\n"
      "add z17.s, z17.s, z21.s\n"
      "add z18.s, z18.s, z20.s\n"
      "add z19.s, z19.s, z16.s\n"
      "ld1rw { z16.s }, p2/Z, [x20]\n"
      "add x20, %x[qp], %[per_layer_right_shift]\n"
      "ld1rw { z0.s }, p2/Z, [x20]\n"
      ".inst 0x04b076f7  // sqrdmulh z23.s, z23.s, z16.s\n"
      ".inst 0x04b07631  // sqrdmulh z17.s, z17.s, z16.s\n"
      "addvl x10, x10, #4\n"
      ".inst 0x04b07652  // sqrdmulh z18.s, z18.s, z16.s\n"
      ".inst 0x04b07673  // sqrdmulh z19.s, z19.s, z16.s\n"
      "tbz %x[flags], #5, 13f\n"
      "and z22.d, z23.d, z0.d\n"
      "and z21.d, z17.d, z0.d\n"
      "and z20.d, z18.d, z0.d\n"
      "and z16.d, z19.d, z0.d\n"
      "asr z22.s, z22.s, #0x1f\n"
      "asr z21.s, z21.s, #0x1f\n"
      "asr z20.s, z20.s, #0x1f\n"
      "asr z16.s, z16.s, #0x1f\n"
      "sqadd z23.s, z23.s, z22.s\n"
      "sqadd z17.s, z17.s, z21.s\n"
      "sqadd z18.s, z18.s, z20.s\n"
      "sqadd z19.s, z19.s, z16.s\n"
      "13:"  // Height 1: no shift correction
      "add x20, %x[qp], %[c_offset]\n"
      "ld1rw { z16.s }, p2/Z, [x20]\n"
      ".inst 0x44828817  // srshl z23.s, p2/M, z23.s, z0.s\n"
      "add z23.s, z23.s, z16.s\n"
      ".inst 0x44828811  // srshl z17.s, p2/M, z17.s, z0.s\n"
      ".inst 0x44828812  // srshl z18.s, p2/M, z18.s, z0.s\n"
      "add z17.s, z17.s, z16.s\n"
      "add z18.s, z18.s, z16.s\n"
      ".inst 0x44828813  // srshl z19.s, p2/M, z19.s, z0.s\n"
      "add x20, %x[qp], %[maxval]\n"
      "ld1rw { z20.s }, p2/Z, [x20]\n"
      "add z19.s, z19.s, z16.s\n"
      "add x20, %x[qp], %[minval]\n"
      "ld1rw { z16.s }, p2/Z, [x20]\n"
      "smin z23.s, p2/M, z23.s, z20.s\n"
      "smin z17.s, p2/M, z17.s, z20.s\n"
      "smin z18.s, p2/M, z18.s, z20.s\n"
      "smin z19.s, p2/M, z19.s, z20.s\n"
      "smax z23.s, p2/M, z23.s, z16.s\n"
      "smax z17.s, p2/M, z17.s, z16.s\n"
      "smax z18.s, p2/M, z18.s, z16.s\n"
      "uzp1 z23.h, z23.h, z17.h\n"
      "smax z19.s, p2/M, z19.s, z16.s\n"
      "uzp1 z16.h, z18.h, z19.h\n"
      "uzp1 z23.b, z23.b, z16.b\n"
      "st1b { z23.b }, p1, [x27]\n"
      "addvl x27, x27, #1\n"
      "14:"  // Height 1: Writeback done
      "decw x9, ALL, MUL #4\n"
      "cmp x9, XZR\n"
      "bgt 2b\n"
      "b 58f\n"
      "15:"  // Height 2
      "mov x10, %x[col_bias]\n"
      "mov z11.s, #0x0\n"
      "mov z12.s, #0x0\n"
      "bic %x[flags], %x[flags], #0x80000000\n"
      "mov z15.b, #0x1\n"
      "ldr x9, [%x[args_ptr], %[offsetof_N]]\n"
      "ldr x28, [%x[args_ptr], %[offsetof_B_ptr]]\n"
      "mov x27, %x[output_ptr]\n"
      "16:"  // Height 2: Column loop
      "mov x20, #0x0\n"
      "whilelt p1.b, x20, x9\n"
      "mov z16.s, #0x0\n"
      "mov z17.s, #0x0\n"
      "mov z18.s, #0x0\n"
      "mov z19.s, #0x0\n"
      "mov z20.s, #0x0\n"
      "mov z21.s, #0x0\n"
      "mov z22.s, #0x0\n"
      "mov z23.s, #0x0\n"
      "17:"  // Height 2: setup done
      "mov x26, #0x0\n"
      "18:"  // Height 2: String loop
      "ldr x20, [%x[args_ptr], %[offsetof_string_lengths]]\n"
      "ldr w25, [x20, x26, LSL #0x2]\n"
      "ldr x21, [%x[args_ptr], %[offsetof_input_offset]]\n"
      "tbz %x[flags], #3, 19f\n"
      "ldr x20, [%x[input_ptr], x26, LSL #0x3]\n"
      "add x20, x20, x21, LSL #3\n"
      "ldr x24, [x20, #0x0]\n"
      "ldr x23, [x20, #0x8]\n"
      "cbnz x26, 20f\n"
      "ldr x20, [%x[args_ptr], %[offsetof_input_initial_col]]\n"
      "add x24, x24, x20\n"
      "add x23, x23, x20\n"
      "b 20f\n"
      "19:"  // Height 2: setup direct input
      "mov x24, %x[input_ptr]\n"
      "add x23, x24, x21\n"
      "20:"  // Height 2: input setup done
      "cmp x25, #0x10\n"
      "ble 23f\n"
      "21:"  // Height 2: Multiply loop: Main loop head
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "ld1rqb { z26.b }, p0/Z, [x23]\n"
      "trn1 z0.d, z1.d, z26.d\n"
      "ld1b { z24.b }, p2/Z, [x28]\n"
      ".inst 0x45d89810  // ummla z16.s, z0.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #1, MUL VL]\n"
      "trn2 z1.d, z1.d, z26.d\n"
      "ld1b { z24.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z26.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45d99814  // ummla z20.s, z0.b, z25.b\n"
      ".inst 0x45d89811  // ummla z17.s, z0.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45da9815  // ummla z21.s, z0.b, z26.b\n"
      ".inst 0x45d99812  // ummla z18.s, z0.b, z25.b\n"
      "ld1b { z26.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z25.b }, p2/Z, [x28, #7, MUL VL]\n"
      "addvl x28, x28, #16\n"
      ".inst 0x45d89816  // ummla z22.s, z0.b, z24.b\n"
      "ld1b { z24.b }, p2/Z, [x28, #-8, MUL VL]\n"
      ".inst 0x45da9813  // ummla z19.s, z0.b, z26.b\n"
      ".inst 0x45d99817  // ummla z23.s, z0.b, z25.b\n"
      "ld1b { z26.b }, p2/Z, [x28, #-7, MUL VL]\n"
      ".inst 0x45d89830  // ummla z16.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #-6, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #-5, MUL VL]\n"
      ".inst 0x45da9834  // ummla z20.s, z1.b, z26.b\n"
      "ld1b { z27.b }, p2/Z, [x28, #-4, MUL VL]\n"
      "ld1b { z26.b }, p2/Z, [x28, #-3, MUL VL]\n"
      ".inst 0x45d99831  // ummla z17.s, z1.b, z25.b\n"
      ".inst 0x45d89835  // ummla z21.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #-2, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #-1, MUL VL]\n"
      ".inst 0x45db9832  // ummla z18.s, z1.b, z27.b\n"
      ".inst 0x45da9836  // ummla z22.s, z1.b, z26.b\n"
      ".inst 0x45d99833  // ummla z19.s, z1.b, z25.b\n"
      ".inst 0x45d89837  // ummla z23.s, z1.b, z24.b\n"
      "add x24, x24, #0x10\n"
      "add x23, x23, #0x10\n"
      "tbnz %x[flags], #31, 22f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "22:"  // Height 2: Multiply loop: unique 3: skip row sum
      "sub x25, x25, #0x10\n"
      "cmp x25, #0x10\n"
      "bgt 21b\n"
      "23:"  // Height 2: Multiply loop: Single iteration only
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "ld1rqb { z27.b }, p0/Z, [x23]\n"
      "trn1 z0.d, z1.d, z27.d\n"
      "ld1b { z24.b }, p2/Z, [x28]\n"
      ".inst 0x45d89810  // ummla z16.s, z0.b, z24.b\n"
      "ld1b { z26.b }, p2/Z, [x28, #1, MUL VL]\n"
      "subs x25, x25, #0x8\n"
      "ld1b { z25.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #3, MUL VL]\n"
      "trn2 z1.d, z1.d, z27.d\n"
      ".inst 0x45da9814  // ummla z20.s, z0.b, z26.b\n"
      "ld1b { z27.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z26.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45d99811  // ummla z17.s, z0.b, z25.b\n"
      ".inst 0x45d89815  // ummla z21.s, z0.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45db9812  // ummla z18.s, z0.b, z27.b\n"
      ".inst 0x45da9816  // ummla z22.s, z0.b, z26.b\n"
      ".inst 0x45d99813  // ummla z19.s, z0.b, z25.b\n"
      ".inst 0x45d89817  // ummla z23.s, z0.b, z24.b\n"
      "addvl x28, x28, #8\n"
      "ble 24f\n"
      "ld1b { z24.b }, p2/Z, [x28]\n"
      ".inst 0x45d89830  // ummla z16.s, z1.b, z24.b\n"
      "ld1b { z24.b }, p2/Z, [x28, #1, MUL VL]\n"
      ".inst 0x45d89834  // ummla z20.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45d99831  // ummla z17.s, z1.b, z25.b\n"
      ".inst 0x45d89835  // ummla z21.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45d99832  // ummla z18.s, z1.b, z25.b\n"
      ".inst 0x45d89836  // ummla z22.s, z1.b, z24.b\n"
      "ld1b { z25.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z24.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45d99833  // ummla z19.s, z1.b, z25.b\n"
      ".inst 0x45d89837  // ummla z23.s, z1.b, z24.b\n"
      "addvl x28, x28, #8\n"
      "24:"  // Height 2: Multiply loop: multiply skip
      "tbnz %x[flags], #31, 25f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "25:"  // Height 2: Multiply loop: unique 4: skip row sum
      "ldr w20, [%x[args_ptr], %[offsetof_num_strings]]\n"
      "add x26, x26, #0x1\n"
      "cmp x26, x20\n"
      "bne 18b\n"
      "uzp1 z24.d, z16.d, z20.d\n"
      "ldr x20, [%x[args_ptr], %[offsetof_output_offset]]\n"
      "uzp2 z16.d, z16.d, z20.d\n"
      "add x23, x27, x20\n"
      "uzp1 z20.d, z17.d, z21.d\n"
      "uzp2 z17.d, z17.d, z21.d\n"
      "uzp1 z21.d, z18.d, z22.d\n"
      "uzp2 z18.d, z18.d, z22.d\n"
      "uzp1 z22.d, z19.d, z23.d\n"
      "uzp2 z19.d, z19.d, z23.d\n"
      "mov z23.d, z24.d\n"
      "tbnz %x[flags], #31, 26f\n"
      "add x20, %x[qp], %[b_offset]\n"
      "ld1rw { z24.s }, p2/Z, [x20]\n"
      ".inst 0x4491a96b  // addp z11.s, p2/m, z11.s, z11.s\n"
      "neg z24.s, p2/M, z24.s\n"
      "mov z12.s, z11.s[3]\n"
      "mov z11.s, z11.s[0]\n"
      "mul z11.s, p2/M, z11.s, z24.s\n"
      "mul z12.s, p2/M, z12.s, z24.s\n"
      "26:"  // Height 2: skip row sum fixup
      "add z23.s, z23.s, z11.s\n"
      "add z20.s, z20.s, z11.s\n"
      "ld1w { z28.s }, p2/Z, [x10]\n"
      "ld1w { z27.s }, p2/Z, [x10, #1, MUL VL]\n"
      "add z21.s, z21.s, z11.s\n"
      "add z22.s, z22.s, z11.s\n"
      "ld1w { z26.s }, p2/Z, [x10, #2, MUL VL]\n"
      "ld1w { z25.s }, p2/Z, [x10, #3, MUL VL]\n"
      "add z16.s, z16.s, z12.s\n"
      "add z17.s, z17.s, z12.s\n"
      "add x20, %x[qp], %[per_layer_mul]\n"
      "orr %x[flags], %x[flags], #0x80000000\n"
      "add z18.s, z18.s, z12.s\n"
      "add z19.s, z19.s, z12.s\n"
      "ld1rw { z24.s }, p2/Z, [x20]\n"
      "add x20, %x[qp], %[per_layer_right_shift]\n"
      "add z23.s, z23.s, z28.s\n"
      "add z20.s, z20.s, z27.s\n"
      "addvl x10, x10, #4\n"
      "add z21.s, z21.s, z26.s\n"
      "add z22.s, z22.s, z25.s\n"
      "add z16.s, z16.s, z28.s\n"
      "add z17.s, z17.s, z27.s\n"
      "ld1rw { z0.s }, p2/Z, [x20]\n"
      "add z18.s, z18.s, z26.s\n"
      "add z19.s, z19.s, z25.s\n"
      ".inst 0x04b876f7  // sqrdmulh z23.s, z23.s, z24.s\n"
      ".inst 0x04b87694  // sqrdmulh z20.s, z20.s, z24.s\n"
      ".inst 0x04b876b5  // sqrdmulh z21.s, z21.s, z24.s\n"
      ".inst 0x04b876d6  // sqrdmulh z22.s, z22.s, z24.s\n"
      ".inst 0x04b87610  // sqrdmulh z16.s, z16.s, z24.s\n"
      ".inst 0x04b87631  // sqrdmulh z17.s, z17.s, z24.s\n"
      ".inst 0x04b87652  // sqrdmulh z18.s, z18.s, z24.s\n"
      ".inst 0x04b87673  // sqrdmulh z19.s, z19.s, z24.s\n"
      "tbz %x[flags], #5, 27f\n"
      "and z24.d, z23.d, z0.d\n"
      "asr z24.s, z24.s, #0x1f\n"
      "sqadd z23.s, z23.s, z24.s\n"
      "and z30.d, z20.d, z0.d\n"
      "and z29.d, z21.d, z0.d\n"
      "and z28.d, z22.d, z0.d\n"
      "and z27.d, z16.d, z0.d\n"
      "and z26.d, z17.d, z0.d\n"
      "and z25.d, z18.d, z0.d\n"
      "and z24.d, z19.d, z0.d\n"
      "asr z30.s, z30.s, #0x1f\n"
      "asr z29.s, z29.s, #0x1f\n"
      "asr z28.s, z28.s, #0x1f\n"
      "asr z27.s, z27.s, #0x1f\n"
      "asr z26.s, z26.s, #0x1f\n"
      "asr z25.s, z25.s, #0x1f\n"
      "asr z24.s, z24.s, #0x1f\n"
      "sqadd z20.s, z20.s, z30.s\n"
      "sqadd z21.s, z21.s, z29.s\n"
      "sqadd z22.s, z22.s, z28.s\n"
      "sqadd z16.s, z16.s, z27.s\n"
      "sqadd z17.s, z17.s, z26.s\n"
      "sqadd z18.s, z18.s, z25.s\n"
      "sqadd z19.s, z19.s, z24.s\n"
      "27:"  // Height 2: no shift correction
      "add x20, %x[qp], %[c_offset]\n"
      "ld1rw { z24.s }, p2/Z, [x20]\n"
      ".inst 0x44828817  // srshl z23.s, p2/M, z23.s, z0.s\n"
      "add z23.s, z23.s, z24.s\n"
      ".inst 0x44828814  // srshl z20.s, p2/M, z20.s, z0.s\n"
      ".inst 0x44828815  // srshl z21.s, p2/M, z21.s, z0.s\n"
      "add z20.s, z20.s, z24.s\n"
      "add z21.s, z21.s, z24.s\n"
      ".inst 0x44828816  // srshl z22.s, p2/M, z22.s, z0.s\n"
      ".inst 0x44828810  // srshl z16.s, p2/M, z16.s, z0.s\n"
      "add z22.s, z22.s, z24.s\n"
      "add z16.s, z16.s, z24.s\n"
      ".inst 0x44828811  // srshl z17.s, p2/M, z17.s, z0.s\n"
      ".inst 0x44828812  // srshl z18.s, p2/M, z18.s, z0.s\n"
      "add z17.s, z17.s, z24.s\n"
      "add z18.s, z18.s, z24.s\n"
      ".inst 0x44828813  // srshl z19.s, p2/M, z19.s, z0.s\n"
      "add x20, %x[qp], %[maxval]\n"
      "ld1rw { z25.s }, p2/Z, [x20]\n"
      "add z19.s, z19.s, z24.s\n"
      "add x20, %x[qp], %[minval]\n"
      "ld1rw { z24.s }, p2/Z, [x20]\n"
      "smin z23.s, p2/M, z23.s, z25.s\n"
      "smin z20.s, p2/M, z20.s, z25.s\n"
      "smin z21.s, p2/M, z21.s, z25.s\n"
      "smin z22.s, p2/M, z22.s, z25.s\n"
      "smin z16.s, p2/M, z16.s, z25.s\n"
      "smin z17.s, p2/M, z17.s, z25.s\n"
      "smin z18.s, p2/M, z18.s, z25.s\n"
      "smin z19.s, p2/M, z19.s, z25.s\n"
      "smax z23.s, p2/M, z23.s, z24.s\n"
      "smax z20.s, p2/M, z20.s, z24.s\n"
      "smax z21.s, p2/M, z21.s, z24.s\n"
      "uzp1 z23.h, z23.h, z20.h\n"
      "smax z22.s, p2/M, z22.s, z24.s\n"
      "smax z16.s, p2/M, z16.s, z24.s\n"
      "uzp1 z20.h, z21.h, z22.h\n"
      "uzp1 z23.b, z23.b, z20.b\n"
      "smax z17.s, p2/M, z17.s, z24.s\n"
      "smax z18.s, p2/M, z18.s, z24.s\n"
      "uzp1 z16.h, z16.h, z17.h\n"
      "st1b { z23.b }, p1, [x27]\n"
      "smax z19.s, p2/M, z19.s, z24.s\n"
      "uzp1 z17.h, z18.h, z19.h\n"
      "uzp1 z16.b, z16.b, z17.b\n"
      "st1b { z16.b }, p1, [x23]\n"
      "addvl x27, x27, #1\n"
      "28:"  // Height 2: Writeback done
      "decw x9, ALL, MUL #4\n"
      "cmp x9, XZR\n"
      "bgt 16b\n"
      "b 58f\n"
      "29:"  // Height 3
      "mov x10, %x[col_bias]\n"
      "mov z11.s, #0x0\n"
      "mov z12.s, #0x0\n"
      "bic %x[flags], %x[flags], #0x80000000\n"
      "mov z13.s, #0x0\n"
      "mov z15.b, #0x1\n"
      "ldr x9, [%x[args_ptr], %[offsetof_N]]\n"
      "ldr x28, [%x[args_ptr], %[offsetof_B_ptr]]\n"
      "mov x27, %x[output_ptr]\n"
      "30:"  // Height 3: Column loop
      "mov x20, #0x0\n"
      "whilelt p1.b, x20, x9\n"
      "mov z16.s, #0x0\n"
      "mov z17.s, #0x0\n"
      "mov z18.s, #0x0\n"
      "mov z19.s, #0x0\n"
      "mov z20.s, #0x0\n"
      "mov z21.s, #0x0\n"
      "mov z22.s, #0x0\n"
      "mov z23.s, #0x0\n"
      "mov z24.s, #0x0\n"
      "mov z25.s, #0x0\n"
      "mov z26.s, #0x0\n"
      "mov z27.s, #0x0\n"
      "mov z28.s, #0x0\n"
      "mov z29.s, #0x0\n"
      "mov z30.s, #0x0\n"
      "mov z31.s, #0x0\n"
      "31:"  // Height 3: setup done
      "mov x26, #0x0\n"
      "32:"  // Height 3: String loop
      "ldr x20, [%x[args_ptr], %[offsetof_string_lengths]]\n"
      "ldr w25, [x20, x26, LSL #0x2]\n"
      "ldr x21, [%x[args_ptr], %[offsetof_input_offset]]\n"
      "tbz %x[flags], #3, 33f\n"
      "ldr x20, [%x[input_ptr], x26, LSL #0x3]\n"
      "add x20, x20, x21, LSL #3\n"
      "ldr x24, [x20, #0x0]\n"
      "ldr x23, [x20, #0x8]\n"
      "ldr x22, [x20, #0x10]\n"
      "cbnz x26, 34f\n"
      "ldr x20, [%x[args_ptr], %[offsetof_input_initial_col]]\n"
      "add x24, x24, x20\n"
      "add x23, x23, x20\n"
      "add x22, x22, x20\n"
      "b 34f\n"
      "33:"  // Height 3: setup direct input
      "mov x24, %x[input_ptr]\n"
      "add x23, x24, x21\n"
      "add x22, x23, x21\n"
      "34:"  // Height 3: input setup done
      "cmp x25, #0x10\n"
      "ble 37f\n"
      "35:"  // Height 3: Multiply loop: Main loop head
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "ld1rqb { z2.b }, p0/Z, [x23]\n"
      "ld1rqb { z3.b }, p0/Z, [x22]\n"
      "trn1 z0.d, z1.d, z2.d\n"
      "trn2 z1.d, z1.d, z2.d\n"
      "ld1b { z4.b }, p2/Z, [x28]\n"
      "trn1 z2.d, z3.d, z5.d\n"
      "trn2 z3.d, z3.d, z5.d\n"
      ".inst 0x45c49810  // ummla z16.s, z0.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #1, MUL VL]\n"
      ".inst 0x45c49858  // ummla z24.s, z2.b, z4.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z9.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45c59814  // ummla z20.s, z0.b, z5.b\n"
      "ld1b { z8.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z7.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45c5985c  // ummla z28.s, z2.b, z5.b\n"
      ".inst 0x45c49811  // ummla z17.s, z0.b, z4.b\n"
      "ld1b { z6.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z5.b }, p2/Z, [x28, #7, MUL VL]\n"
      "addvl x28, x28, #16\n"
      ".inst 0x45c49859  // ummla z25.s, z2.b, z4.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #-8, MUL VL]\n"
      ".inst 0x45c99815  // ummla z21.s, z0.b, z9.b\n"
      ".inst 0x45c9985d  // ummla z29.s, z2.b, z9.b\n"
      "ld1b { z10.b }, p2/Z, [x28, #-7, MUL VL]\n"
      ".inst 0x45c89812  // ummla z18.s, z0.b, z8.b\n"
      ".inst 0x45c8985a  // ummla z26.s, z2.b, z8.b\n"
      "ld1b { z9.b }, p2/Z, [x28, #-6, MUL VL]\n"
      "ld1b { z8.b }, p2/Z, [x28, #-5, MUL VL]\n"
      ".inst 0x45c79816  // ummla z22.s, z0.b, z7.b\n"
      ".inst 0x45c7985e  // ummla z30.s, z2.b, z7.b\n"
      "ld1b { z7.b }, p2/Z, [x28, #-4, MUL VL]\n"
      "add x24, x24, #0x10\n"
      ".inst 0x45c69813  // ummla z19.s, z0.b, z6.b\n"
      ".inst 0x45c6985b  // ummla z27.s, z2.b, z6.b\n"
      "ld1b { z6.b }, p2/Z, [x28, #-3, MUL VL]\n"
      "add x23, x23, #0x10\n"
      ".inst 0x45c59817  // ummla z23.s, z0.b, z5.b\n"
      ".inst 0x45c5985f  // ummla z31.s, z2.b, z5.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #-2, MUL VL]\n"
      "add x22, x22, #0x10\n"
      ".inst 0x45c49830  // ummla z16.s, z1.b, z4.b\n"
      ".inst 0x45c49878  // ummla z24.s, z3.b, z4.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #-1, MUL VL]\n"
      ".inst 0x45ca9834  // ummla z20.s, z1.b, z10.b\n"
      ".inst 0x45ca987c  // ummla z28.s, z3.b, z10.b\n"
      ".inst 0x45c99831  // ummla z17.s, z1.b, z9.b\n"
      ".inst 0x45c99879  // ummla z25.s, z3.b, z9.b\n"
      ".inst 0x45c89835  // ummla z21.s, z1.b, z8.b\n"
      ".inst 0x45c8987d  // ummla z29.s, z3.b, z8.b\n"
      ".inst 0x45c79832  // ummla z18.s, z1.b, z7.b\n"
      ".inst 0x45c7987a  // ummla z26.s, z3.b, z7.b\n"
      ".inst 0x45c69836  // ummla z22.s, z1.b, z6.b\n"
      ".inst 0x45c6987e  // ummla z30.s, z3.b, z6.b\n"
      ".inst 0x45c59833  // ummla z19.s, z1.b, z5.b\n"
      ".inst 0x45c5987b  // ummla z27.s, z3.b, z5.b\n"
      ".inst 0x45c49837  // ummla z23.s, z1.b, z4.b\n"
      ".inst 0x45c4987f  // ummla z31.s, z3.b, z4.b\n"
      "tbnz %x[flags], #31, 36f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z13.s, z2.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "udot z13.s, z3.b, z15.b\n"
      "36:"  // Height 3: Multiply loop: unique 5: skip row sum
      "sub x25, x25, #0x10\n"
      "cmp x25, #0x10\n"
      "bgt 35b\n"
      "37:"  // Height 3: Multiply loop: Single iteration only
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "ld1rqb { z2.b }, p0/Z, [x23]\n"
      "ld1rqb { z3.b }, p0/Z, [x22]\n"
      "trn1 z0.d, z1.d, z2.d\n"
      "trn2 z1.d, z1.d, z2.d\n"
      "ld1b { z5.b }, p2/Z, [x28]\n"
      "trn1 z2.d, z3.d, z4.d\n"
      "trn2 z3.d, z3.d, z4.d\n"
      ".inst 0x45c59810  // ummla z16.s, z0.b, z5.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #1, MUL VL]\n"
      ".inst 0x45c59858  // ummla z24.s, z2.b, z5.b\n"
      "ld1b { z9.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z8.b }, p2/Z, [x28, #3, MUL VL]\n"
      "subs x25, x25, #0x8\n"
      "ld1b { z7.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z6.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45c49814  // ummla z20.s, z0.b, z4.b\n"
      ".inst 0x45c4985c  // ummla z28.s, z2.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z4.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45c99811  // ummla z17.s, z0.b, z9.b\n"
      ".inst 0x45c99859  // ummla z25.s, z2.b, z9.b\n"
      ".inst 0x45c89815  // ummla z21.s, z0.b, z8.b\n"
      ".inst 0x45c8985d  // ummla z29.s, z2.b, z8.b\n"
      "addvl x28, x28, #8\n"
      ".inst 0x45c79812  // ummla z18.s, z0.b, z7.b\n"
      ".inst 0x45c7985a  // ummla z26.s, z2.b, z7.b\n"
      ".inst 0x45c69816  // ummla z22.s, z0.b, z6.b\n"
      ".inst 0x45c6985e  // ummla z30.s, z2.b, z6.b\n"
      ".inst 0x45c59813  // ummla z19.s, z0.b, z5.b\n"
      ".inst 0x45c5985b  // ummla z27.s, z2.b, z5.b\n"
      ".inst 0x45c49817  // ummla z23.s, z0.b, z4.b\n"
      ".inst 0x45c4985f  // ummla z31.s, z2.b, z4.b\n"
      "ble 38f\n"
      "ld1b { z4.b }, p2/Z, [x28]\n"
      ".inst 0x45c49830  // ummla z16.s, z1.b, z4.b\n"
      ".inst 0x45c49878  // ummla z24.s, z3.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #1, MUL VL]\n"
      "ld1b { z4.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z8.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45c59834  // ummla z20.s, z1.b, z5.b\n"
      ".inst 0x45c5987c  // ummla z28.s, z3.b, z5.b\n"
      "ld1b { z7.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z6.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45c49831  // ummla z17.s, z1.b, z4.b\n"
      ".inst 0x45c49879  // ummla z25.s, z3.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z4.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45c89835  // ummla z21.s, z1.b, z8.b\n"
      ".inst 0x45c8987d  // ummla z29.s, z3.b, z8.b\n"
      ".inst 0x45c79832  // ummla z18.s, z1.b, z7.b\n"
      ".inst 0x45c7987a  // ummla z26.s, z3.b, z7.b\n"
      "addvl x28, x28, #8\n"
      ".inst 0x45c69836  // ummla z22.s, z1.b, z6.b\n"
      ".inst 0x45c6987e  // ummla z30.s, z3.b, z6.b\n"
      ".inst 0x45c59833  // ummla z19.s, z1.b, z5.b\n"
      ".inst 0x45c5987b  // ummla z27.s, z3.b, z5.b\n"
      ".inst 0x45c49837  // ummla z23.s, z1.b, z4.b\n"
      ".inst 0x45c4987f  // ummla z31.s, z3.b, z4.b\n"
      "38:"  // Height 3: Multiply loop: multiply skip
      "tbnz %x[flags], #31, 39f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z13.s, z2.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "udot z13.s, z3.b, z15.b\n"
      "39:"  // Height 3: Multiply loop: unique 6: skip row sum
      "ldr w20, [%x[args_ptr], %[offsetof_num_strings]]\n"
      "add x26, x26, #0x1\n"
      "cmp x26, x20\n"
      "bne 32b\n"
      "ldr x20, [%x[args_ptr], %[offsetof_output_offset]]\n"
      "uzp1 z0.d, z16.d, z20.d\n"
      "add x23, x27, x20\n"
      "uzp2 z16.d, z16.d, z20.d\n"
      "uzp1 z20.d, z17.d, z21.d\n"
      "uzp2 z17.d, z17.d, z21.d\n"
      "add x22, x23, x20\n"
      "uzp1 z21.d, z18.d, z22.d\n"
      "uzp2 z18.d, z18.d, z22.d\n"
      "uzp1 z22.d, z19.d, z23.d\n"
      "uzp2 z19.d, z19.d, z23.d\n"
      "uzp1 z24.d, z24.d, z28.d\n"
      "uzp1 z25.d, z25.d, z29.d\n"
      "uzp1 z26.d, z26.d, z30.d\n"
      "uzp1 z27.d, z27.d, z31.d\n"
      "mov z31.d, z0.d\n"
      "tbnz %x[flags], #31, 40f\n"
      "add x20, %x[qp], %[b_offset]\n"
      "ld1rw { z23.s }, p2/Z, [x20]\n"
      ".inst 0x4491a96b  // addp z11.s, p2/m, z11.s, z11.s\n"
      ".inst 0x4491a9ad  // addp z13.s, p2/m, z13.s, z13.s\n"
      "neg z23.s, p2/M, z23.s\n"
      "mov z12.s, z11.s[3]\n"
      "mov z11.s, z11.s[0]\n"
      "mul z11.s, p2/M, z11.s, z23.s\n"
      "mov z13.s, z13.s[0]\n"
      "mul z12.s, p2/M, z12.s, z23.s\n"
      "mul z13.s, p2/M, z13.s, z23.s\n"
      "40:"  // Height 3: skip row sum fixup
      "add z31.s, z31.s, z11.s\n"
      "add z20.s, z20.s, z11.s\n"
      "ld1w { z0.s }, p2/Z, [x10]\n"
      "ld1w { z30.s }, p2/Z, [x10, #1, MUL VL]\n"
      "add z21.s, z21.s, z11.s\n"
      "add z22.s, z22.s, z11.s\n"
      "ld1w { z29.s }, p2/Z, [x10, #2, MUL VL]\n"
      "ld1w { z28.s }, p2/Z, [x10, #3, MUL VL]\n"
      "add z16.s, z16.s, z12.s\n"
      "add z17.s, z17.s, z12.s\n"
      "add x20, %x[qp], %[per_layer_mul]\n"
      "orr %x[flags], %x[flags], #0x80000000\n"
      "add z18.s, z18.s, z12.s\n"
      "add z19.s, z19.s, z12.s\n"
      "ld1rw { z23.s }, p2/Z, [x20]\n"
      "add x20, %x[qp], %[per_layer_right_shift]\n"
      "add z24.s, z24.s, z13.s\n"
      "add z25.s, z25.s, z13.s\n"
      "addvl x10, x10, #4\n"
      "add z26.s, z26.s, z13.s\n"
      "add z27.s, z27.s, z13.s\n"
      "add z31.s, z31.s, z0.s\n"
      "add z20.s, z20.s, z30.s\n"
      "add z21.s, z21.s, z29.s\n"
      "add z22.s, z22.s, z28.s\n"
      "add z16.s, z16.s, z0.s\n"
      "add z17.s, z17.s, z30.s\n"
      "add z18.s, z18.s, z29.s\n"
      "add z19.s, z19.s, z28.s\n"
      "add z24.s, z24.s, z0.s\n"
      "add z25.s, z25.s, z30.s\n"
      "ld1rw { z0.s }, p2/Z, [x20]\n"
      "add z26.s, z26.s, z29.s\n"
      "add z27.s, z27.s, z28.s\n"
      ".inst 0x04b777ff  // sqrdmulh z31.s, z31.s, z23.s\n"
      ".inst 0x04b77694  // sqrdmulh z20.s, z20.s, z23.s\n"
      ".inst 0x04b776b5  // sqrdmulh z21.s, z21.s, z23.s\n"
      ".inst 0x04b776d6  // sqrdmulh z22.s, z22.s, z23.s\n"
      ".inst 0x04b77610  // sqrdmulh z16.s, z16.s, z23.s\n"
      ".inst 0x04b77631  // sqrdmulh z17.s, z17.s, z23.s\n"
      ".inst 0x04b77652  // sqrdmulh z18.s, z18.s, z23.s\n"
      ".inst 0x04b77673  // sqrdmulh z19.s, z19.s, z23.s\n"
      ".inst 0x04b77718  // sqrdmulh z24.s, z24.s, z23.s\n"
      ".inst 0x04b77739  // sqrdmulh z25.s, z25.s, z23.s\n"
      ".inst 0x04b7775a  // sqrdmulh z26.s, z26.s, z23.s\n"
      ".inst 0x04b7777b  // sqrdmulh z27.s, z27.s, z23.s\n"
      "tbz %x[flags], #5, 41f\n"
      "and z1.d, z31.d, z0.d\n"
      "and z30.d, z20.d, z0.d\n"
      "and z29.d, z21.d, z0.d\n"
      "and z28.d, z22.d, z0.d\n"
      "and z23.d, z16.d, z0.d\n"
      "asr z1.s, z1.s, #0x1f\n"
      "asr z30.s, z30.s, #0x1f\n"
      "asr z29.s, z29.s, #0x1f\n"
      "asr z28.s, z28.s, #0x1f\n"
      "asr z23.s, z23.s, #0x1f\n"
      "sqadd z31.s, z31.s, z1.s\n"
      "sqadd z20.s, z20.s, z30.s\n"
      "sqadd z21.s, z21.s, z29.s\n"
      "sqadd z22.s, z22.s, z28.s\n"
      "sqadd z16.s, z16.s, z23.s\n"
      "and z3.d, z17.d, z0.d\n"
      "and z2.d, z18.d, z0.d\n"
      "and z1.d, z19.d, z0.d\n"
      "and z30.d, z24.d, z0.d\n"
      "and z29.d, z25.d, z0.d\n"
      "and z28.d, z26.d, z0.d\n"
      "and z23.d, z27.d, z0.d\n"
      "asr z3.s, z3.s, #0x1f\n"
      "asr z2.s, z2.s, #0x1f\n"
      "asr z1.s, z1.s, #0x1f\n"
      "asr z30.s, z30.s, #0x1f\n"
      "asr z29.s, z29.s, #0x1f\n"
      "asr z28.s, z28.s, #0x1f\n"
      "asr z23.s, z23.s, #0x1f\n"
      "sqadd z17.s, z17.s, z3.s\n"
      "sqadd z18.s, z18.s, z2.s\n"
      "sqadd z19.s, z19.s, z1.s\n"
      "sqadd z24.s, z24.s, z30.s\n"
      "sqadd z25.s, z25.s, z29.s\n"
      "sqadd z26.s, z26.s, z28.s\n"
      "sqadd z27.s, z27.s, z23.s\n"
      "41:"  // Height 3: no shift correction
      "add x20, %x[qp], %[c_offset]\n"
      "ld1rw { z23.s }, p2/Z, [x20]\n"
      ".inst 0x4482881f  // srshl z31.s, p2/M, z31.s, z0.s\n"
      "add z31.s, z31.s, z23.s\n"
      ".inst 0x44828814  // srshl z20.s, p2/M, z20.s, z0.s\n"
      ".inst 0x44828815  // srshl z21.s, p2/M, z21.s, z0.s\n"
      "add z20.s, z20.s, z23.s\n"
      "add z21.s, z21.s, z23.s\n"
      ".inst 0x44828816  // srshl z22.s, p2/M, z22.s, z0.s\n"
      ".inst 0x44828810  // srshl z16.s, p2/M, z16.s, z0.s\n"
      "add z22.s, z22.s, z23.s\n"
      "add z16.s, z16.s, z23.s\n"
      ".inst 0x44828811  // srshl z17.s, p2/M, z17.s, z0.s\n"
      ".inst 0x44828812  // srshl z18.s, p2/M, z18.s, z0.s\n"
      "add z17.s, z17.s, z23.s\n"
      "add z18.s, z18.s, z23.s\n"
      ".inst 0x44828813  // srshl z19.s, p2/M, z19.s, z0.s\n"
      ".inst 0x44828818  // srshl z24.s, p2/M, z24.s, z0.s\n"
      "add z19.s, z19.s, z23.s\n"
      "add z24.s, z24.s, z23.s\n"
      ".inst 0x44828819  // srshl z25.s, p2/M, z25.s, z0.s\n"
      ".inst 0x4482881a  // srshl z26.s, p2/M, z26.s, z0.s\n"
      "add z25.s, z25.s, z23.s\n"
      "add z26.s, z26.s, z23.s\n"
      ".inst 0x4482881b  // srshl z27.s, p2/M, z27.s, z0.s\n"
      "add x20, %x[qp], %[maxval]\n"
      "ld1rw { z28.s }, p2/Z, [x20]\n"
      "add z27.s, z27.s, z23.s\n"
      "add x20, %x[qp], %[minval]\n"
      "ld1rw { z23.s }, p2/Z, [x20]\n"
      "smin z31.s, p2/M, z31.s, z28.s\n"
      "smin z20.s, p2/M, z20.s, z28.s\n"
      "smin z21.s, p2/M, z21.s, z28.s\n"
      "smin z22.s, p2/M, z22.s, z28.s\n"
      "smin z16.s, p2/M, z16.s, z28.s\n"
      "smin z17.s, p2/M, z17.s, z28.s\n"
      "smin z18.s, p2/M, z18.s, z28.s\n"
      "smin z19.s, p2/M, z19.s, z28.s\n"
      "smin z24.s, p2/M, z24.s, z28.s\n"
      "smin z25.s, p2/M, z25.s, z28.s\n"
      "smin z26.s, p2/M, z26.s, z28.s\n"
      "smin z27.s, p2/M, z27.s, z28.s\n"
      "smax z31.s, p2/M, z31.s, z23.s\n"
      "smax z20.s, p2/M, z20.s, z23.s\n"
      "smax z21.s, p2/M, z21.s, z23.s\n"
      "uzp1 z31.h, z31.h, z20.h\n"
      "smax z22.s, p2/M, z22.s, z23.s\n"
      "smax z16.s, p2/M, z16.s, z23.s\n"
      "uzp1 z20.h, z21.h, z22.h\n"
      "uzp1 z31.b, z31.b, z20.b\n"
      "smax z17.s, p2/M, z17.s, z23.s\n"
      "smax z18.s, p2/M, z18.s, z23.s\n"
      "uzp1 z16.h, z16.h, z17.h\n"
      "st1b { z31.b }, p1, [x27]\n"
      "smax z19.s, p2/M, z19.s, z23.s\n"
      "smax z24.s, p2/M, z24.s, z23.s\n"
      "uzp1 z17.h, z18.h, z19.h\n"
      "uzp1 z16.b, z16.b, z17.b\n"
      "smax z25.s, p2/M, z25.s, z23.s\n"
      "smax z26.s, p2/M, z26.s, z23.s\n"
      "uzp1 z24.h, z24.h, z25.h\n"
      "st1b { z16.b }, p1, [x23]\n"
      "smax z27.s, p2/M, z27.s, z23.s\n"
      "uzp1 z16.h, z26.h, z27.h\n"
      "uzp1 z24.b, z24.b, z16.b\n"
      "st1b { z24.b }, p1, [x22]\n"
      "addvl x27, x27, #1\n"
      "42:"  // Height 3: Writeback done
      "decw x9, ALL, MUL #4\n"
      "cmp x9, XZR\n"
      "bgt 30b\n"
      "b 58f\n"
      "43:"  // Height 4
      "ldr x21, [%x[args_ptr], %[offsetof_output_offset]]\n"
      "mov x20, #0x4\n"
      "mov x10, %x[col_bias]\n"
      "mov z11.s, #0x0\n"
      "mov z12.s, #0x0\n"
      "mov z13.s, #0x0\n"
      "bic %x[flags], %x[flags], #0x80000000\n"
      "ldr x9, [%x[args_ptr], %[offsetof_N]]\n"
      "mov z14.s, #0x0\n"
      "mov z15.b, #0x1\n"
      "ldr x28, [%x[args_ptr], %[offsetof_B_ptr]]\n"
      "mov x27, %x[output_ptr]\n"
      "madd %x[output_ptr], x21, x20, %x[output_ptr]\n"
      "44:"  // Height 4: Column loop
      "mov x20, #0x0\n"
      "whilelt p1.b, x20, x9\n"
      "mov z16.s, #0x0\n"
      "mov z17.s, #0x0\n"
      "mov z18.s, #0x0\n"
      "mov z19.s, #0x0\n"
      "mov z20.s, #0x0\n"
      "mov z21.s, #0x0\n"
      "mov z22.s, #0x0\n"
      "mov z23.s, #0x0\n"
      "mov z24.s, #0x0\n"
      "mov z25.s, #0x0\n"
      "mov z26.s, #0x0\n"
      "mov z27.s, #0x0\n"
      "mov z28.s, #0x0\n"
      "mov z29.s, #0x0\n"
      "mov z30.s, #0x0\n"
      "mov z31.s, #0x0\n"
      "45:"  // Height 4: setup done
      "mov x26, #0x0\n"
      "46:"  // Height 4: String loop
      "ldr x20, [%x[args_ptr], %[offsetof_string_lengths]]\n"
      "ldr w25, [x20, x26, LSL #0x2]\n"
      "ldr x21, [%x[args_ptr], %[offsetof_input_offset]]\n"
      "tbz %x[flags], #3, 47f\n"
      "ldr x20, [%x[input_ptr], x26, LSL #0x3]\n"
      "add x20, x20, x21, LSL #3\n"
      "ldr x24, [x20, #0x0]\n"
      "ldr x23, [x20, #0x8]\n"
      "ldr x22, [x20, #0x10]\n"
      "ldr x21, [x20, #0x18]\n"
      "cbnz x26, 48f\n"
      "ldr x20, [%x[args_ptr], %[offsetof_input_initial_col]]\n"
      "add x24, x24, x20\n"
      "add x23, x23, x20\n"
      "add x22, x22, x20\n"
      "add x21, x21, x20\n"
      "b 48f\n"
      "47:"  // Height 4: setup direct input
      "mov x24, %x[input_ptr]\n"
      "add x23, x24, x21\n"
      "add x22, x23, x21\n"
      "add x21, x22, x21\n"
      "48:"  // Height 4: input setup done
      "cmp x25, #0x10\n"
      "ble 51f\n"
      "49:"  // Height 4: Multiply loop: Main loop head
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "ld1rqb { z2.b }, p0/Z, [x23]\n"
      "trn1 z0.d, z1.d, z2.d\n"
      "ld1rqb { z3.b }, p0/Z, [x22]\n"
      "ld1rqb { z5.b }, p0/Z, [x21]\n"
      "trn2 z1.d, z1.d, z2.d\n"
      "trn1 z2.d, z3.d, z5.d\n"
      "ld1b { z4.b }, p2/Z, [x28]\n"
      "trn2 z3.d, z3.d, z5.d\n"
      ".inst 0x45c49810  // ummla z16.s, z0.b, z4.b\n"
      ".inst 0x45c49858  // ummla z24.s, z2.b, z4.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #1, MUL VL]\n"
      "ld1b { z5.b }, p2/Z, [x28, #2, MUL VL]\n"
      ".inst 0x45c49814  // ummla z20.s, z0.b, z4.b\n"
      ".inst 0x45c4985c  // ummla z28.s, z2.b, z4.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #3, MUL VL]\n"
      "ld1b { z8.b }, p2/Z, [x28, #4, MUL VL]\n"
      ".inst 0x45c59811  // ummla z17.s, z0.b, z5.b\n"
      ".inst 0x45c59859  // ummla z25.s, z2.b, z5.b\n"
      "ld1b { z7.b }, p2/Z, [x28, #5, MUL VL]\n"
      "ld1b { z6.b }, p2/Z, [x28, #6, MUL VL]\n"
      ".inst 0x45c49815  // ummla z21.s, z0.b, z4.b\n"
      ".inst 0x45c4985d  // ummla z29.s, z2.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #7, MUL VL]\n"
      "addvl x28, x28, #16\n"
      "ld1b { z4.b }, p2/Z, [x28, #-8, MUL VL]\n"
      ".inst 0x45c89812  // ummla z18.s, z0.b, z8.b\n"
      ".inst 0x45c8985a  // ummla z26.s, z2.b, z8.b\n"
      ".inst 0x45c79816  // ummla z22.s, z0.b, z7.b\n"
      "ld1b { z10.b }, p2/Z, [x28, #-7, MUL VL]\n"
      "ld1b { z9.b }, p2/Z, [x28, #-6, MUL VL]\n"
      ".inst 0x45c7985e  // ummla z30.s, z2.b, z7.b\n"
      ".inst 0x45c69813  // ummla z19.s, z0.b, z6.b\n"
      "ld1b { z8.b }, p2/Z, [x28, #-5, MUL VL]\n"
      "ld1b { z7.b }, p2/Z, [x28, #-4, MUL VL]\n"
      ".inst 0x45c6985b  // ummla z27.s, z2.b, z6.b\n"
      ".inst 0x45c59817  // ummla z23.s, z0.b, z5.b\n"
      "ld1b { z6.b }, p2/Z, [x28, #-3, MUL VL]\n"
      "add x24, x24, #0x10\n"
      ".inst 0x45c5985f  // ummla z31.s, z2.b, z5.b\n"
      ".inst 0x45c49830  // ummla z16.s, z1.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #-2, MUL VL]\n"
      "add x23, x23, #0x10\n"
      ".inst 0x45c49878  // ummla z24.s, z3.b, z4.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #-1, MUL VL]\n"
      ".inst 0x45ca9834  // ummla z20.s, z1.b, z10.b\n"
      "add x22, x22, #0x10\n"
      ".inst 0x45ca987c  // ummla z28.s, z3.b, z10.b\n"
      ".inst 0x45c99831  // ummla z17.s, z1.b, z9.b\n"
      "add x21, x21, #0x10\n"
      ".inst 0x45c99879  // ummla z25.s, z3.b, z9.b\n"
      ".inst 0x45c89835  // ummla z21.s, z1.b, z8.b\n"
      ".inst 0x45c8987d  // ummla z29.s, z3.b, z8.b\n"
      ".inst 0x45c79832  // ummla z18.s, z1.b, z7.b\n"
      ".inst 0x45c7987a  // ummla z26.s, z3.b, z7.b\n"
      ".inst 0x45c69836  // ummla z22.s, z1.b, z6.b\n"
      ".inst 0x45c6987e  // ummla z30.s, z3.b, z6.b\n"
      ".inst 0x45c59833  // ummla z19.s, z1.b, z5.b\n"
      ".inst 0x45c5987b  // ummla z27.s, z3.b, z5.b\n"
      ".inst 0x45c49837  // ummla z23.s, z1.b, z4.b\n"
      ".inst 0x45c4987f  // ummla z31.s, z3.b, z4.b\n"
      "tbnz %x[flags], #31, 50f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z13.s, z2.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "udot z13.s, z3.b, z15.b\n"
      "50:"  // Height 4: Multiply loop: unique 7: skip row sum
      "sub x25, x25, #0x10\n"
      "cmp x25, #0x10\n"
      "bgt 49b\n"
      "51:"  // Height 4: Multiply loop: Single iteration only
      "whilelt p0.b, XZR, x25\n"
      "ld1rqb { z1.b }, p0/Z, [x24]\n"
      "ld1rqb { z2.b }, p0/Z, [x23]\n"
      "trn1 z0.d, z1.d, z2.d\n"
      "ld1rqb { z3.b }, p0/Z, [x22]\n"
      "ld1rqb { z5.b }, p0/Z, [x21]\n"
      "trn2 z1.d, z1.d, z2.d\n"
      "trn1 z2.d, z3.d, z5.d\n"
      "ld1b { z4.b }, p2/Z, [x28]\n"
      "trn2 z3.d, z3.d, z5.d\n"
      ".inst 0x45c49810  // ummla z16.s, z0.b, z4.b\n"
      ".inst 0x45c49858  // ummla z24.s, z2.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #1, MUL VL]\n"
      "ld1b { z4.b }, p2/Z, [x28, #2, MUL VL]\n"
      "subs x25, x25, #0x8\n"
      ".inst 0x45c59814  // ummla z20.s, z0.b, z5.b\n"
      "ld1b { z8.b }, p2/Z, [x28, #3, MUL VL]\n"
      "ld1b { z7.b }, p2/Z, [x28, #4, MUL VL]\n"
      ".inst 0x45c5985c  // ummla z28.s, z2.b, z5.b\n"
      ".inst 0x45c49811  // ummla z17.s, z0.b, z4.b\n"
      "ld1b { z6.b }, p2/Z, [x28, #5, MUL VL]\n"
      "ld1b { z5.b }, p2/Z, [x28, #6, MUL VL]\n"
      ".inst 0x45c49859  // ummla z25.s, z2.b, z4.b\n"
      ".inst 0x45c89815  // ummla z21.s, z0.b, z8.b\n"
      "ld1b { z4.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45c8985d  // ummla z29.s, z2.b, z8.b\n"
      ".inst 0x45c79812  // ummla z18.s, z0.b, z7.b\n"
      "addvl x28, x28, #8\n"
      ".inst 0x45c7985a  // ummla z26.s, z2.b, z7.b\n"
      ".inst 0x45c69816  // ummla z22.s, z0.b, z6.b\n"
      ".inst 0x45c6985e  // ummla z30.s, z2.b, z6.b\n"
      ".inst 0x45c59813  // ummla z19.s, z0.b, z5.b\n"
      ".inst 0x45c5985b  // ummla z27.s, z2.b, z5.b\n"
      ".inst 0x45c49817  // ummla z23.s, z0.b, z4.b\n"
      ".inst 0x45c4985f  // ummla z31.s, z2.b, z4.b\n"
      "ble 52f\n"
      "ld1b { z4.b }, p2/Z, [x28]\n"
      ".inst 0x45c49830  // ummla z16.s, z1.b, z4.b\n"
      ".inst 0x45c49878  // ummla z24.s, z3.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #1, MUL VL]\n"
      "ld1b { z4.b }, p2/Z, [x28, #2, MUL VL]\n"
      "ld1b { z8.b }, p2/Z, [x28, #3, MUL VL]\n"
      ".inst 0x45c59834  // ummla z20.s, z1.b, z5.b\n"
      ".inst 0x45c5987c  // ummla z28.s, z3.b, z5.b\n"
      "ld1b { z7.b }, p2/Z, [x28, #4, MUL VL]\n"
      "ld1b { z6.b }, p2/Z, [x28, #5, MUL VL]\n"
      ".inst 0x45c49831  // ummla z17.s, z1.b, z4.b\n"
      ".inst 0x45c49879  // ummla z25.s, z3.b, z4.b\n"
      "ld1b { z5.b }, p2/Z, [x28, #6, MUL VL]\n"
      "ld1b { z4.b }, p2/Z, [x28, #7, MUL VL]\n"
      ".inst 0x45c89835  // ummla z21.s, z1.b, z8.b\n"
      ".inst 0x45c8987d  // ummla z29.s, z3.b, z8.b\n"
      ".inst 0x45c79832  // ummla z18.s, z1.b, z7.b\n"
      ".inst 0x45c7987a  // ummla z26.s, z3.b, z7.b\n"
      "addvl x28, x28, #8\n"
      ".inst 0x45c69836  // ummla z22.s, z1.b, z6.b\n"
      ".inst 0x45c6987e  // ummla z30.s, z3.b, z6.b\n"
      ".inst 0x45c59833  // ummla z19.s, z1.b, z5.b\n"
      ".inst 0x45c5987b  // ummla z27.s, z3.b, z5.b\n"
      ".inst 0x45c49837  // ummla z23.s, z1.b, z4.b\n"
      ".inst 0x45c4987f  // ummla z31.s, z3.b, z4.b\n"
      "52:"  // Height 4: Multiply loop: multiply skip
      "tbnz %x[flags], #31, 53f\n"
      "udot z11.s, z0.b, z15.b\n"
      "udot z13.s, z2.b, z15.b\n"
      "udot z11.s, z1.b, z15.b\n"
      "udot z13.s, z3.b, z15.b\n"
      "53:"  // Height 4: Multiply loop: unique 8: skip row sum
      "ldr w20, [%x[args_ptr], %[offsetof_num_strings]]\n"
      "add x26, x26, #0x1\n"
      "cmp x26, x20\n"
      "bne 46b\n"
      "ldr x20, [%x[args_ptr], %[offsetof_output_offset]]\n"
      "uzp1 z0.d, z16.d, z20.d\n"
      "add x23, x27, x20\n"
      "add x22, x23, x20\n"
      "uzp2 z16.d, z16.d, z20.d\n"
      "uzp1 z20.d, z17.d, z21.d\n"
      "add x21, x22, x20\n"
      "uzp2 z17.d, z17.d, z21.d\n"
      "uzp1 z21.d, z18.d, z22.d\n"
      "uzp2 z18.d, z18.d, z22.d\n"
      "uzp1 z22.d, z19.d, z23.d\n"
      "uzp2 z19.d, z19.d, z23.d\n"
      "uzp1 z23.d, z24.d, z28.d\n"
      "uzp2 z24.d, z24.d, z28.d\n"
      "uzp1 z28.d, z25.d, z29.d\n"
      "uzp2 z25.d, z25.d, z29.d\n"
      "uzp1 z29.d, z26.d, z30.d\n"
      "uzp2 z26.d, z26.d, z30.d\n"
      "uzp1 z30.d, z27.d, z31.d\n"
      "uzp2 z27.d, z27.d, z31.d\n"
      "mov z31.d, z0.d\n"
      "tbnz %x[flags], #31, 54f\n"
      "add x20, %x[qp], %[b_offset]\n"
      "ld1rw { z0.s }, p2/Z, [x20]\n"
      ".inst 0x4491a96b  // addp z11.s, p2/m, z11.s, z11.s\n"
      ".inst 0x4491a9ad  // addp z13.s, p2/m, z13.s, z13.s\n"
      "neg z0.s, p2/M, z0.s\n"
      "mov z12.s, z11.s[3]\n"
      "mov z11.s, z11.s[0]\n"
      "mul z11.s, p2/M, z11.s, z0.s\n"
      "mov z14.s, z13.s[3]\n"
      "mov z13.s, z13.s[0]\n"
      "mul z12.s, p2/M, z12.s, z0.s\n"
      "mul z13.s, p2/M, z13.s, z0.s\n"
      "mul z14.s, p2/M, z14.s, z0.s\n"
      "54:"  // Height 4: skip row sum fixup
      "add z31.s, z31.s, z11.s\n"
      "add z20.s, z20.s, z11.s\n"
      "ld1w { z4.s }, p2/Z, [x10]\n"
      "ld1w { z0.s }, p2/Z, [x10, #1, MUL VL]\n"
      "add z21.s, z21.s, z11.s\n"
      "add z22.s, z22.s, z11.s\n"
      "ld1w { z3.s }, p2/Z, [x10, #2, MUL VL]\n"
      "ld1w { z2.s }, p2/Z, [x10, #3, MUL VL]\n"
      "add z16.s, z16.s, z12.s\n"
      "add z17.s, z17.s, z12.s\n"
      "add x20, %x[qp], %[per_layer_mul]\n"
      "orr %x[flags], %x[flags], #0x80000000\n"
      "add z18.s, z18.s, z12.s\n"
      "add z19.s, z19.s, z12.s\n"
      "ld1rw { z1.s }, p2/Z, [x20]\n"
      "add x20, %x[qp], %[per_layer_right_shift]\n"
      "add z23.s, z23.s, z13.s\n"
      "add z28.s, z28.s, z13.s\n"
      "addvl x10, x10, #4\n"
      "add z29.s, z29.s, z13.s\n"
      "add z30.s, z30.s, z13.s\n"
      "add z24.s, z24.s, z14.s\n"
      "add z25.s, z25.s, z14.s\n"
      "add z26.s, z26.s, z14.s\n"
      "add z27.s, z27.s, z14.s\n"
      "add z31.s, z31.s, z4.s\n"
      "add z20.s, z20.s, z0.s\n"
      "add z21.s, z21.s, z3.s\n"
      "add z22.s, z22.s, z2.s\n"
      "add z16.s, z16.s, z4.s\n"
      "add z17.s, z17.s, z0.s\n"
      "add z18.s, z18.s, z3.s\n"
      "add z19.s, z19.s, z2.s\n"
      "add z23.s, z23.s, z4.s\n"
      "add z28.s, z28.s, z0.s\n"
      "add z29.s, z29.s, z3.s\n"
      "add z30.s, z30.s, z2.s\n"
      "add z24.s, z24.s, z4.s\n"
      "add z25.s, z25.s, z0.s\n"
      "ld1rw { z0.s }, p2/Z, [x20]\n"
      "add z26.s, z26.s, z3.s\n"
      "add z27.s, z27.s, z2.s\n"
      ".inst 0x04a177ff  // sqrdmulh z31.s, z31.s, z1.s\n"
      ".inst 0x04a17694  // sqrdmulh z20.s, z20.s, z1.s\n"
      ".inst 0x04a176b5  // sqrdmulh z21.s, z21.s, z1.s\n"
      ".inst 0x04a176d6  // sqrdmulh z22.s, z22.s, z1.s\n"
      ".inst 0x04a17610  // sqrdmulh z16.s, z16.s, z1.s\n"
      ".inst 0x04a17631  // sqrdmulh z17.s, z17.s, z1.s\n"
      ".inst 0x04a17652  // sqrdmulh z18.s, z18.s, z1.s\n"
      ".inst 0x04a17673  // sqrdmulh z19.s, z19.s, z1.s\n"
      ".inst 0x04a176f7  // sqrdmulh z23.s, z23.s, z1.s\n"
      ".inst 0x04a1779c  // sqrdmulh z28.s, z28.s, z1.s\n"
      ".inst 0x04a177bd  // sqrdmulh z29.s, z29.s, z1.s\n"
      ".inst 0x04a177de  // sqrdmulh z30.s, z30.s, z1.s\n"
      ".inst 0x04a17718  // sqrdmulh z24.s, z24.s, z1.s\n"
      ".inst 0x04a17739  // sqrdmulh z25.s, z25.s, z1.s\n"
      ".inst 0x04a1775a  // sqrdmulh z26.s, z26.s, z1.s\n"
      ".inst 0x04a1777b  // sqrdmulh z27.s, z27.s, z1.s\n"
      "tbz %x[flags], #5, 55f\n"
      "and z2.d, z31.d, z0.d\n"
      "and z1.d, z20.d, z0.d\n"
      "asr z2.s, z2.s, #0x1f\n"
      "asr z1.s, z1.s, #0x1f\n"
      "sqadd z31.s, z31.s, z2.s\n"
      "sqadd z20.s, z20.s, z1.s\n"
      "and z7.d, z21.d, z0.d\n"
      "and z6.d, z22.d, z0.d\n"
      "and z5.d, z16.d, z0.d\n"
      "and z4.d, z17.d, z0.d\n"
      "and z3.d, z18.d, z0.d\n"
      "and z2.d, z19.d, z0.d\n"
      "and z1.d, z23.d, z0.d\n"
      "asr z7.s, z7.s, #0x1f\n"
      "asr z6.s, z6.s, #0x1f\n"
      "asr z5.s, z5.s, #0x1f\n"
      "asr z4.s, z4.s, #0x1f\n"
      "asr z3.s, z3.s, #0x1f\n"
      "asr z2.s, z2.s, #0x1f\n"
      "asr z1.s, z1.s, #0x1f\n"
      "sqadd z21.s, z21.s, z7.s\n"
      "sqadd z22.s, z22.s, z6.s\n"
      "sqadd z16.s, z16.s, z5.s\n"
      "sqadd z17.s, z17.s, z4.s\n"
      "sqadd z18.s, z18.s, z3.s\n"
      "sqadd z19.s, z19.s, z2.s\n"
      "sqadd z23.s, z23.s, z1.s\n"
      "and z7.d, z28.d, z0.d\n"
      "and z6.d, z29.d, z0.d\n"
      "and z5.d, z30.d, z0.d\n"
      "and z4.d, z24.d, z0.d\n"
      "and z3.d, z25.d, z0.d\n"
      "and z2.d, z26.d, z0.d\n"
      "and z1.d, z27.d, z0.d\n"
      "asr z7.s, z7.s, #0x1f\n"
      "asr z6.s, z6.s, #0x1f\n"
      "asr z5.s, z5.s, #0x1f\n"
      "asr z4.s, z4.s, #0x1f\n"
      "asr z3.s, z3.s, #0x1f\n"
      "asr z2.s, z2.s, #0x1f\n"
      "asr z1.s, z1.s, #0x1f\n"
      "sqadd z28.s, z28.s, z7.s\n"
      "sqadd z29.s, z29.s, z6.s\n"
      "sqadd z30.s, z30.s, z5.s\n"
      "sqadd z24.s, z24.s, z4.s\n"
      "sqadd z25.s, z25.s, z3.s\n"
      "sqadd z26.s, z26.s, z2.s\n"
      "sqadd z27.s, z27.s, z1.s\n"
      "55:"  // Height 4: no shift correction
      "add x20, %x[qp], %[c_offset]\n"
      "ld1rw { z2.s }, p2/Z, [x20]\n"
      ".inst 0x4482881f  // srshl z31.s, p2/M, z31.s, z0.s\n"
      "add z31.s, z31.s, z2.s\n"
      ".inst 0x44828814  // srshl z20.s, p2/M, z20.s, z0.s\n"
      ".inst 0x44828815  // srshl z21.s, p2/M, z21.s, z0.s\n"
      "add z20.s, z20.s, z2.s\n"
      "add z21.s, z21.s, z2.s\n"
      ".inst 0x44828816  // srshl z22.s, p2/M, z22.s, z0.s\n"
      ".inst 0x44828810  // srshl z16.s, p2/M, z16.s, z0.s\n"
      "add z22.s, z22.s, z2.s\n"
      "add z16.s, z16.s, z2.s\n"
      ".inst 0x44828811  // srshl z17.s, p2/M, z17.s, z0.s\n"
      ".inst 0x44828812  // srshl z18.s, p2/M, z18.s, z0.s\n"
      "add z17.s, z17.s, z2.s\n"
      "add z18.s, z18.s, z2.s\n"
      ".inst 0x44828813  // srshl z19.s, p2/M, z19.s, z0.s\n"
      ".inst 0x44828817  // srshl z23.s, p2/M, z23.s, z0.s\n"
      "add z19.s, z19.s, z2.s\n"
      "add z23.s, z23.s, z2.s\n"
      ".inst 0x4482881c  // srshl z28.s, p2/M, z28.s, z0.s\n"
      ".inst 0x4482881d  // srshl z29.s, p2/M, z29.s, z0.s\n"
      "add z28.s, z28.s, z2.s\n"
      "add z29.s, z29.s, z2.s\n"
      ".inst 0x4482881e  // srshl z30.s, p2/M, z30.s, z0.s\n"
      ".inst 0x44828818  // srshl z24.s, p2/M, z24.s, z0.s\n"
      "add z30.s, z30.s, z2.s\n"
      "add z24.s, z24.s, z2.s\n"
      ".inst 0x44828819  // srshl z25.s, p2/M, z25.s, z0.s\n"
      ".inst 0x4482881a  // srshl z26.s, p2/M, z26.s, z0.s\n"
      "add z25.s, z25.s, z2.s\n"
      "add z26.s, z26.s, z2.s\n"
      ".inst 0x4482881b  // srshl z27.s, p2/M, z27.s, z0.s\n"
      "add x20, %x[qp], %[maxval]\n"
      "ld1rw { z1.s }, p2/Z, [x20]\n"
      "add z27.s, z27.s, z2.s\n"
      "add x20, %x[qp], %[minval]\n"
      "ld1rw { z0.s }, p2/Z, [x20]\n"
      "smin z31.s, p2/M, z31.s, z1.s\n"
      "smin z20.s, p2/M, z20.s, z1.s\n"
      "smin z21.s, p2/M, z21.s, z1.s\n"
      "smin z22.s, p2/M, z22.s, z1.s\n"
      "smin z16.s, p2/M, z16.s, z1.s\n"
      "smin z17.s, p2/M, z17.s, z1.s\n"
      "smin z18.s, p2/M, z18.s, z1.s\n"
      "smin z19.s, p2/M, z19.s, z1.s\n"
      "smin z23.s, p2/M, z23.s, z1.s\n"
      "smin z28.s, p2/M, z28.s, z1.s\n"
      "smin z29.s, p2/M, z29.s, z1.s\n"
      "smin z30.s, p2/M, z30.s, z1.s\n"
      "smin z24.s, p2/M, z24.s, z1.s\n"
      "smin z25.s, p2/M, z25.s, z1.s\n"
      "smin z26.s, p2/M, z26.s, z1.s\n"
      "smin z27.s, p2/M, z27.s, z1.s\n"
      "smax z31.s, p2/M, z31.s, z0.s\n"
      "smax z20.s, p2/M, z20.s, z0.s\n"
      "smax z21.s, p2/M, z21.s, z0.s\n"
      "uzp1 z31.h, z31.h, z20.h\n"
      "smax z22.s, p2/M, z22.s, z0.s\n"
      "smax z16.s, p2/M, z16.s, z0.s\n"
      "uzp1 z20.h, z21.h, z22.h\n"
      "uzp1 z31.b, z31.b, z20.b\n"
      "smax z17.s, p2/M, z17.s, z0.s\n"
      "smax z18.s, p2/M, z18.s, z0.s\n"
      "uzp1 z16.h, z16.h, z17.h\n"
      "st1b { z31.b }, p1, [x27]\n"
      "smax z19.s, p2/M, z19.s, z0.s\n"
      "smax z23.s, p2/M, z23.s, z0.s\n"
      "uzp1 z17.h, z18.h, z19.h\n"
      "uzp1 z16.b, z16.b, z17.b\n"
      "smax z28.s, p2/M, z28.s, z0.s\n"
      "smax z29.s, p2/M, z29.s, z0.s\n"
      "uzp1 z23.h, z23.h, z28.h\n"
      "st1b { z16.b }, p1, [x23]\n"
      "smax z30.s, p2/M, z30.s, z0.s\n"
      "smax z24.s, p2/M, z24.s, z0.s\n"
      "uzp1 z16.h, z29.h, z30.h\n"
      "uzp1 z23.b, z23.b, z16.b\n"
      "smax z25.s, p2/M, z25.s, z0.s\n"
      "smax z26.s, p2/M, z26.s, z0.s\n"
      "uzp1 z24.h, z24.h, z25.h\n"
      "st1b { z23.b }, p1, [x22]\n"
      "smax z27.s, p2/M, z27.s, z0.s\n"
      "uzp1 z16.h, z26.h, z27.h\n"
      "uzp1 z24.b, z24.b, z16.b\n"
      "st1b { z24.b }, p1, [x21]\n"
      "addvl x27, x27, #1\n"
      "56:"  // Height 4: Writeback done
      "decw x9, ALL, MUL #4\n"
      "cmp x9, XZR\n"
      "bgt 44b\n"
      "subs %x[M], %x[M], #0x4\n"
      "beq 58f\n"
      "ldr x21, [%x[args_ptr], %[offsetof_input_offset]]\n"
      "tbz %x[flags], #3, 57f\n"
      "add x21, x21, #0x4\n"
      "str x21, [%x[args_ptr], %[offsetof_input_offset]]\n"
      "b 1b\n"
      "57:"  // Update direct input
      "mov x20, #0x4\n"
      "madd %x[input_ptr], x20, x21, %x[input_ptr]\n"
      "b 1b\n"
      "58:"  // Exit
      : [M] "+&r" (M), [flags] "+&r" (flags), [input_ptr] "+&r" (input_ptr), [output_ptr] "+&r" (output_ptr)
      : [args_ptr] "r" (&ka), [b_offset] "I" (offsetof(Requantize32, b_offset)), [c_offset] "I" (offsetof(Requantize32, c_offset)), [col_bias] "r" (col_bias), [maxval] "I" (offsetof(Requantize32, maxval)), [minval] "I" (offsetof(Requantize32, minval)), [offsetof_B_ptr] "I" (offsetof(KernelArgs, B_ptr)), [offsetof_N] "I" (offsetof(KernelArgs, N)), [offsetof_input_initial_col] "I" (offsetof(KernelArgs, input_initial_col)), [offsetof_input_offset] "I" (offsetof(KernelArgs, input_offset)), [offsetof_num_strings] "I" (offsetof(KernelArgs, num_strings)), [offsetof_output_offset] "I" (offsetof(KernelArgs, output_offset)), [offsetof_string_lengths] "I" (offsetof(KernelArgs, string_lengths)), [per_layer_mul] "I" (offsetof(Requantize32, per_layer_mul)), [per_layer_right_shift] "I" (offsetof(Requantize32, per_layer_right_shift)), [qp] "r" (qp)
      : "cc", "memory", "p0", "p1", "p2", "x9", "x10", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8", "z9", "z10", "z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21", "z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31"
    );
}

} // namespace arm_gemm
#endif  // ARM_COMPUTE_ENABLE_SVE