summaryrefslogtreecommitdiffstats
path: root/third_party/aom/aom_dsp/mips/convolve8_horiz_dspr2.c
blob: f9c6879abd64aa685f9500fba186cf8ae4dfe65f (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
/*
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */

#include <assert.h>
#include <stdio.h>

#include "config/aom_dsp_rtcd.h"

#include "aom_dsp/mips/convolve_common_dspr2.h"
#include "aom_dsp/aom_dsp_common.h"
#include "aom_dsp/aom_filter.h"
#include "aom_ports/mem.h"

#if HAVE_DSPR2
static void convolve_horiz_4_dspr2(const uint8_t *src, int32_t src_stride,
                                   uint8_t *dst, int32_t dst_stride,
                                   const int16_t *filter_x0, int32_t h) {
  int32_t y;
  uint8_t *cm = aom_ff_cropTbl;
  int32_t vector1b, vector2b, vector3b, vector4b;
  int32_t Temp1, Temp2, Temp3, Temp4;
  uint32_t vector4a = 64;
  uint32_t tp1, tp2;
  uint32_t p1, p2, p3, p4;
  uint32_t n1, n2, n3, n4;
  uint32_t tn1, tn2;

  vector1b = ((const int32_t *)filter_x0)[0];
  vector2b = ((const int32_t *)filter_x0)[1];
  vector3b = ((const int32_t *)filter_x0)[2];
  vector4b = ((const int32_t *)filter_x0)[3];

  for (y = h; y--;) {
    /* prefetch data to cache memory */
    prefetch_load(src + src_stride);
    prefetch_load(src + src_stride + 32);
    prefetch_store(dst + dst_stride);

    __asm__ __volatile__(
        "ulw              %[tp1],      0(%[src])                      \n\t"
        "ulw              %[tp2],      4(%[src])                      \n\t"

        /* even 1. pixel */
        "mtlo             %[vector4a], $ac3                           \n\t"
        "mthi             $zero,       $ac3                           \n\t"
        "preceu.ph.qbr    %[p1],       %[tp1]                         \n\t"
        "preceu.ph.qbl    %[p2],       %[tp1]                         \n\t"
        "preceu.ph.qbr    %[p3],       %[tp2]                         \n\t"
        "preceu.ph.qbl    %[p4],       %[tp2]                         \n\t"
        "dpa.w.ph         $ac3,        %[p1],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac3,        %[p2],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac3,        %[p3],          %[vector3b]    \n\t"
        "ulw              %[tn2],      8(%[src])                      \n\t"
        "dpa.w.ph         $ac3,        %[p4],          %[vector4b]    \n\t"
        "extp             %[Temp1],    $ac3,           31             \n\t"

        /* even 2. pixel */
        "mtlo             %[vector4a], $ac2                           \n\t"
        "mthi             $zero,       $ac2                           \n\t"
        "preceu.ph.qbr    %[p1],       %[tn2]                         \n\t"
        "balign           %[tn1],      %[tn2],         3              \n\t"
        "balign           %[tn2],      %[tp2],         3              \n\t"
        "balign           %[tp2],      %[tp1],         3              \n\t"
        "dpa.w.ph         $ac2,        %[p2],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac2,        %[p3],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac2,        %[p4],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac2,        %[p1],          %[vector4b]    \n\t"
        "extp             %[Temp3],    $ac2,           31             \n\t"

        /* odd 1. pixel */
        "lbux             %[tp1],      %[Temp1](%[cm])                \n\t"
        "mtlo             %[vector4a], $ac3                           \n\t"
        "mthi             $zero,       $ac3                           \n\t"
        "preceu.ph.qbr    %[n1],       %[tp2]                         \n\t"
        "preceu.ph.qbl    %[n2],       %[tp2]                         \n\t"
        "preceu.ph.qbr    %[n3],       %[tn2]                         \n\t"
        "preceu.ph.qbl    %[n4],       %[tn2]                         \n\t"
        "dpa.w.ph         $ac3,        %[n1],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac3,        %[n2],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac3,        %[n3],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac3,        %[n4],          %[vector4b]    \n\t"
        "extp             %[Temp2],    $ac3,           31             \n\t"

        /* odd 2. pixel */
        "lbux             %[tp2],      %[Temp3](%[cm])                \n\t"
        "mtlo             %[vector4a], $ac2                           \n\t"
        "mthi             $zero,       $ac2                           \n\t"
        "preceu.ph.qbr    %[n1],       %[tn1]                         \n\t"
        "dpa.w.ph         $ac2,        %[n2],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac2,        %[n3],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac2,        %[n4],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac2,        %[n1],          %[vector4b]    \n\t"
        "extp             %[Temp4],    $ac2,           31             \n\t"

        /* clamp */
        "lbux             %[tn1],      %[Temp2](%[cm])                \n\t"
        "lbux             %[n2],       %[Temp4](%[cm])                \n\t"

        /* store bytes */
        "sb               %[tp1],      0(%[dst])                      \n\t"
        "sb               %[tn1],      1(%[dst])                      \n\t"
        "sb               %[tp2],      2(%[dst])                      \n\t"
        "sb               %[n2],       3(%[dst])                      \n\t"

        : [tp1] "=&r"(tp1), [tp2] "=&r"(tp2), [tn1] "=&r"(tn1),
          [tn2] "=&r"(tn2), [p1] "=&r"(p1), [p2] "=&r"(p2), [p3] "=&r"(p3),
          [p4] "=&r"(p4), [n1] "=&r"(n1), [n2] "=&r"(n2), [n3] "=&r"(n3),
          [n4] "=&r"(n4), [Temp1] "=&r"(Temp1), [Temp2] "=&r"(Temp2),
          [Temp3] "=&r"(Temp3), [Temp4] "=&r"(Temp4)
        : [vector1b] "r"(vector1b), [vector2b] "r"(vector2b),
          [vector3b] "r"(vector3b), [vector4b] "r"(vector4b),
          [vector4a] "r"(vector4a), [cm] "r"(cm), [dst] "r"(dst),
          [src] "r"(src));

    /* Next row... */
    src += src_stride;
    dst += dst_stride;
  }
}

static void convolve_horiz_8_dspr2(const uint8_t *src, int32_t src_stride,
                                   uint8_t *dst, int32_t dst_stride,
                                   const int16_t *filter_x0, int32_t h) {
  int32_t y;
  uint8_t *cm = aom_ff_cropTbl;
  uint32_t vector4a = 64;
  int32_t vector1b, vector2b, vector3b, vector4b;
  int32_t Temp1, Temp2, Temp3;
  uint32_t tp1, tp2;
  uint32_t p1, p2, p3, p4, n1;
  uint32_t tn1, tn2, tn3;
  uint32_t st0, st1;

  vector1b = ((const int32_t *)filter_x0)[0];
  vector2b = ((const int32_t *)filter_x0)[1];
  vector3b = ((const int32_t *)filter_x0)[2];
  vector4b = ((const int32_t *)filter_x0)[3];

  for (y = h; y--;) {
    /* prefetch data to cache memory */
    prefetch_load(src + src_stride);
    prefetch_load(src + src_stride + 32);
    prefetch_store(dst + dst_stride);

    __asm__ __volatile__(
        "ulw              %[tp1],      0(%[src])                      \n\t"
        "ulw              %[tp2],      4(%[src])                      \n\t"

        /* even 1. pixel */
        "mtlo             %[vector4a], $ac3                           \n\t"
        "mthi             $zero,       $ac3                           \n\t"
        "mtlo             %[vector4a], $ac2                           \n\t"
        "mthi             $zero,       $ac2                           \n\t"
        "preceu.ph.qbr    %[p1],       %[tp1]                         \n\t"
        "preceu.ph.qbl    %[p2],       %[tp1]                         \n\t"
        "preceu.ph.qbr    %[p3],       %[tp2]                         \n\t"
        "preceu.ph.qbl    %[p4],       %[tp2]                         \n\t"
        "ulw              %[tn2],      8(%[src])                      \n\t"
        "dpa.w.ph         $ac3,        %[p1],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac3,        %[p2],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac3,        %[p3],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac3,        %[p4],          %[vector4b]    \n\t"
        "extp             %[Temp1],    $ac3,           31             \n\t"

        /* even 2. pixel */
        "preceu.ph.qbr    %[p1],       %[tn2]                         \n\t"
        "preceu.ph.qbl    %[n1],       %[tn2]                         \n\t"
        "ulw              %[tn1],      12(%[src])                     \n\t"
        "dpa.w.ph         $ac2,        %[p2],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac2,        %[p3],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac2,        %[p4],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac2,        %[p1],          %[vector4b]    \n\t"
        "extp             %[Temp3],    $ac2,           31             \n\t"

        /* even 3. pixel */
        "lbux             %[st0],      %[Temp1](%[cm])                \n\t"
        "mtlo             %[vector4a], $ac1                           \n\t"
        "mthi             $zero,       $ac1                           \n\t"
        "preceu.ph.qbr    %[p2],       %[tn1]                         \n\t"
        "dpa.w.ph         $ac1,        %[p3],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac1,        %[p4],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac1,        %[p1],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac1,        %[n1],          %[vector4b]    \n\t"
        "extp             %[Temp1],    $ac1,           31             \n\t"

        /* even 4. pixel */
        "mtlo             %[vector4a], $ac2                           \n\t"
        "mthi             $zero,       $ac2                           \n\t"
        "mtlo             %[vector4a], $ac3                           \n\t"
        "mthi             $zero,       $ac3                           \n\t"
        "sb               %[st0],      0(%[dst])                      \n\t"
        "lbux             %[st1],      %[Temp3](%[cm])                \n\t"

        "balign           %[tn3],      %[tn1],         3              \n\t"
        "balign           %[tn1],      %[tn2],         3              \n\t"
        "balign           %[tn2],      %[tp2],         3              \n\t"
        "balign           %[tp2],      %[tp1],         3              \n\t"

        "dpa.w.ph         $ac2,        %[p4],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac2,        %[p1],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac2,        %[n1],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac2,        %[p2],          %[vector4b]    \n\t"
        "extp             %[Temp3],    $ac2,           31             \n\t"

        "lbux             %[st0],      %[Temp1](%[cm])                \n\t"

        /* odd 1. pixel */
        "mtlo             %[vector4a], $ac1                           \n\t"
        "mthi             $zero,       $ac1                           \n\t"
        "sb               %[st1],      2(%[dst])                      \n\t"
        "preceu.ph.qbr    %[p1],       %[tp2]                         \n\t"
        "preceu.ph.qbl    %[p2],       %[tp2]                         \n\t"
        "preceu.ph.qbr    %[p3],       %[tn2]                         \n\t"
        "preceu.ph.qbl    %[p4],       %[tn2]                         \n\t"
        "sb               %[st0],      4(%[dst])                      \n\t"
        "dpa.w.ph         $ac3,        %[p1],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac3,        %[p2],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac3,        %[p3],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac3,        %[p4],          %[vector4b]    \n\t"
        "extp             %[Temp2],    $ac3,           31             \n\t"

        /* odd 2. pixel */
        "mtlo             %[vector4a], $ac3                           \n\t"
        "mthi             $zero,       $ac3                           \n\t"
        "mtlo             %[vector4a], $ac2                           \n\t"
        "mthi             $zero,       $ac2                           \n\t"
        "preceu.ph.qbr    %[p1],       %[tn1]                         \n\t"
        "preceu.ph.qbl    %[n1],       %[tn1]                         \n\t"
        "lbux             %[st0],      %[Temp3](%[cm])                \n\t"
        "dpa.w.ph         $ac1,        %[p2],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac1,        %[p3],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac1,        %[p4],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac1,        %[p1],          %[vector4b]    \n\t"
        "extp             %[Temp3],    $ac1,           31             \n\t"

        /* odd 3. pixel */
        "lbux             %[st1],      %[Temp2](%[cm])                \n\t"
        "preceu.ph.qbr    %[p2],       %[tn3]                         \n\t"
        "dpa.w.ph         $ac3,        %[p3],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac3,        %[p4],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac3,        %[p1],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac3,        %[n1],          %[vector4b]    \n\t"
        "extp             %[Temp2],    $ac3,           31             \n\t"

        /* odd 4. pixel */
        "sb               %[st1],      1(%[dst])                      \n\t"
        "sb               %[st0],      6(%[dst])                      \n\t"
        "dpa.w.ph         $ac2,        %[p4],          %[vector1b]    \n\t"
        "dpa.w.ph         $ac2,        %[p1],          %[vector2b]    \n\t"
        "dpa.w.ph         $ac2,        %[n1],          %[vector3b]    \n\t"
        "dpa.w.ph         $ac2,        %[p2],          %[vector4b]    \n\t"
        "extp             %[Temp1],    $ac2,           31             \n\t"

        /* clamp */
        "lbux             %[p4],       %[Temp3](%[cm])                \n\t"
        "lbux             %[p2],       %[Temp2](%[cm])                \n\t"
        "lbux             %[n1],       %[Temp1](%[cm])                \n\t"

        /* store bytes */
        "sb               %[p4],       3(%[dst])                      \n\t"
        "sb               %[p2],       5(%[dst])                      \n\t"
        "sb               %[n1],       7(%[dst])                      \n\t"

        : [tp1] "=&r"(tp1), [tp2] "=&r"(tp2), [tn1] "=&r"(tn1),
          [tn2] "=&r"(tn2), [tn3] "=&r"(tn3), [st0] "=&r"(st0),
          [st1] "=&r"(st1), [p1] "=&r"(p1), [p2] "=&r"(p2), [p3] "=&r"(p3),
          [p4] "=&r"(p4), [n1] "=&r"(n1), [Temp1] "=&r"(Temp1),
          [Temp2] "=&r"(Temp2), [Temp3] "=&r"(Temp3)
        : [vector1b] "r"(vector1b), [vector2b] "r"(vector2b),
          [vector3b] "r"(vector3b), [vector4b] "r"(vector4b),
          [vector4a] "r"(vector4a), [cm] "r"(cm), [dst] "r"(dst),
          [src] "r"(src));

    /* Next row... */
    src += src_stride;
    dst += dst_stride;
  }
}

static void convolve_horiz_16_dspr2(const uint8_t *src_ptr, int32_t src_stride,
                                    uint8_t *dst_ptr, int32_t dst_stride,
                                    const int16_t *filter_x0, int32_t h,
                                    int32_t count) {
  int32_t y, c;
  const uint8_t *src;
  uint8_t *dst;
  uint8_t *cm = aom_ff_cropTbl;
  uint32_t vector_64 = 64;
  int32_t filter12, filter34, filter56, filter78;
  int32_t Temp1, Temp2, Temp3;
  uint32_t qload1, qload2, qload3;
  uint32_t p1, p2, p3, p4, p5;
  uint32_t st1, st2, st3;

  filter12 = ((const int32_t *)filter_x0)[0];
  filter34 = ((const int32_t *)filter_x0)[1];
  filter56 = ((const int32_t *)filter_x0)[2];
  filter78 = ((const int32_t *)filter_x0)[3];

  for (y = h; y--;) {
    src = src_ptr;
    dst = dst_ptr;

    /* prefetch data to cache memory */
    prefetch_load(src_ptr + src_stride);
    prefetch_load(src_ptr + src_stride + 32);
    prefetch_store(dst_ptr + dst_stride);

    for (c = 0; c < count; c++) {
      __asm__ __volatile__(
          "ulw              %[qload1],    0(%[src])                    \n\t"
          "ulw              %[qload2],    4(%[src])                    \n\t"

          /* even 1. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* even 1 */
          "mthi             $zero,        $ac1                         \n\t"
          "mtlo             %[vector_64], $ac2                         \n\t" /* even 2 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload1]                    \n\t"
          "preceu.ph.qbl    %[p2],        %[qload1]                    \n\t"
          "preceu.ph.qbr    %[p3],        %[qload2]                    \n\t"
          "preceu.ph.qbl    %[p4],        %[qload2]                    \n\t"
          "ulw              %[qload3],    8(%[src])                    \n\t"
          "dpa.w.ph         $ac1,         %[p1],          %[filter12]  \n\t" /* even 1 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter34]  \n\t" /* even 1 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter56]  \n\t" /* even 1 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter78]  \n\t" /* even 1 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* even 1 */

          /* even 2. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* even 3 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload3]                    \n\t"
          "preceu.ph.qbl    %[p5],        %[qload3]                    \n\t"
          "ulw              %[qload1],    12(%[src])                   \n\t"
          "dpa.w.ph         $ac2,         %[p2],          %[filter12]  \n\t" /* even 1 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter34]  \n\t" /* even 1 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter56]  \n\t" /* even 1 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter78]  \n\t" /* even 1 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* even 1 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* even 1 */

          /* even 3. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* even 4 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbr    %[p2],        %[qload1]                    \n\t"
          "sb               %[st1],       0(%[dst])                    \n\t" /* even 1 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter12]  \n\t" /* even 3 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter34]  \n\t" /* even 3 */
          "dpa.w.ph         $ac3,         %[p1],          %[filter56]  \n\t" /* even 3 */
          "dpa.w.ph         $ac3,         %[p5],          %[filter78]  \n\t" /* even 3 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* even 3 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* even 1 */

          /* even 4. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* even 5 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbl    %[p3],        %[qload1]                    \n\t"
          "sb               %[st2],       2(%[dst])                    \n\t" /* even 1 */
          "ulw              %[qload2],    16(%[src])                   \n\t"
          "dpa.w.ph         $ac1,         %[p4],          %[filter12]  \n\t" /* even 4 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter34]  \n\t" /* even 4 */
          "dpa.w.ph         $ac1,         %[p5],          %[filter56]  \n\t" /* even 4 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter78]  \n\t" /* even 4 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* even 4 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* even 3 */

          /* even 5. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* even 6 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbr    %[p4],        %[qload2]                    \n\t"
          "sb               %[st3],       4(%[dst])                    \n\t" /* even 3 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter12]  \n\t" /* even 5 */
          "dpa.w.ph         $ac2,         %[p5],          %[filter34]  \n\t" /* even 5 */
          "dpa.w.ph         $ac2,         %[p2],          %[filter56]  \n\t" /* even 5 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter78]  \n\t" /* even 5 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* even 5 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* even 4 */

          /* even 6. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* even 7 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbl    %[p1],        %[qload2]                    \n\t"
          "sb               %[st1],       6(%[dst])                    \n\t" /* even 4 */
          "ulw              %[qload3],    20(%[src])                   \n\t"
          "dpa.w.ph         $ac3,         %[p5],          %[filter12]  \n\t" /* even 6 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter34]  \n\t" /* even 6 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter56]  \n\t" /* even 6 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter78]  \n\t" /* even 6 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* even 6 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* even 5 */

          /* even 7. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* even 8 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p5],        %[qload3]                    \n\t"
          "sb               %[st2],       8(%[dst])                    \n\t" /* even 5 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter12]  \n\t" /* even 7 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter34]  \n\t" /* even 7 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter56]  \n\t" /* even 7 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter78]  \n\t" /* even 7 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* even 7 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* even 6 */

          /* even 8. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* odd 1 */
          "mthi             $zero,        $ac3                         \n\t"
          "dpa.w.ph         $ac2,         %[p3],          %[filter12]  \n\t" /* even 8 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter34]  \n\t" /* even 8 */
          "sb               %[st3],       10(%[dst])                   \n\t" /* even 6 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter56]  \n\t" /* even 8 */
          "dpa.w.ph         $ac2,         %[p5],          %[filter78]  \n\t" /* even 8 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* even 8 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* even 7 */

          /* ODD pixels */
          "ulw              %[qload1],    1(%[src])                    \n\t"
          "ulw              %[qload2],    5(%[src])                    \n\t"

          /* odd 1. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* odd 2 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload1]                    \n\t"
          "preceu.ph.qbl    %[p2],        %[qload1]                    \n\t"
          "preceu.ph.qbr    %[p3],        %[qload2]                    \n\t"
          "preceu.ph.qbl    %[p4],        %[qload2]                    \n\t"
          "sb               %[st1],       12(%[dst])                   \n\t" /* even 7 */
          "ulw              %[qload3],    9(%[src])                    \n\t"
          "dpa.w.ph         $ac3,         %[p1],          %[filter12]  \n\t" /* odd 1 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter34]  \n\t" /* odd 1 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter56]  \n\t" /* odd 1 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter78]  \n\t" /* odd 1 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* odd 1 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* even 8 */

          /* odd 2. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* odd 3 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload3]                    \n\t"
          "preceu.ph.qbl    %[p5],        %[qload3]                    \n\t"
          "sb               %[st2],       14(%[dst])                   \n\t" /* even 8 */
          "ulw              %[qload1],    13(%[src])                   \n\t"
          "dpa.w.ph         $ac1,         %[p2],          %[filter12]  \n\t" /* odd 2 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter34]  \n\t" /* odd 2 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter56]  \n\t" /* odd 2 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter78]  \n\t" /* odd 2 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* odd 2 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* odd 1 */

          /* odd 3. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* odd 4 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbr    %[p2],        %[qload1]                    \n\t"
          "sb               %[st3],       1(%[dst])                    \n\t" /* odd 1 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter12]  \n\t" /* odd 3 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter34]  \n\t" /* odd 3 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter56]  \n\t" /* odd 3 */
          "dpa.w.ph         $ac2,         %[p5],          %[filter78]  \n\t" /* odd 3 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* odd 3 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* odd 2 */

          /* odd 4. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* odd 5 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbl    %[p3],        %[qload1]                    \n\t"
          "sb               %[st1],       3(%[dst])                    \n\t" /* odd 2 */
          "ulw              %[qload2],    17(%[src])                   \n\t"
          "dpa.w.ph         $ac3,         %[p4],          %[filter12]  \n\t" /* odd 4 */
          "dpa.w.ph         $ac3,         %[p1],          %[filter34]  \n\t" /* odd 4 */
          "dpa.w.ph         $ac3,         %[p5],          %[filter56]  \n\t" /* odd 4 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter78]  \n\t" /* odd 4 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* odd 4 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* odd 3 */

          /* odd 5. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* odd 6 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p4],        %[qload2]                    \n\t"
          "sb               %[st2],       5(%[dst])                    \n\t" /* odd 3 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter12]  \n\t" /* odd 5 */
          "dpa.w.ph         $ac1,         %[p5],          %[filter34]  \n\t" /* odd 5 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter56]  \n\t" /* odd 5 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter78]  \n\t" /* odd 5 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* odd 5 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* odd 4 */

          /* odd 6. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* odd 7 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbl    %[p1],        %[qload2]                    \n\t"
          "sb               %[st3],       7(%[dst])                    \n\t" /* odd 4 */
          "ulw              %[qload3],    21(%[src])                   \n\t"
          "dpa.w.ph         $ac2,         %[p5],          %[filter12]  \n\t" /* odd 6 */
          "dpa.w.ph         $ac2,         %[p2],          %[filter34]  \n\t" /* odd 6 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter56]  \n\t" /* odd 6 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter78]  \n\t" /* odd 6 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* odd 6 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* odd 5 */

          /* odd 7. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* odd 8 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbr    %[p5],        %[qload3]                    \n\t"
          "sb               %[st1],       9(%[dst])                    \n\t" /* odd 5 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter12]  \n\t" /* odd 7 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter34]  \n\t" /* odd 7 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter56]  \n\t" /* odd 7 */
          "dpa.w.ph         $ac3,         %[p1],          %[filter78]  \n\t" /* odd 7 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* odd 7 */

          /* odd 8. pixel */
          "dpa.w.ph         $ac1,         %[p3],          %[filter12]  \n\t" /* odd 8 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter34]  \n\t" /* odd 8 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter56]  \n\t" /* odd 8 */
          "dpa.w.ph         $ac1,         %[p5],          %[filter78]  \n\t" /* odd 8 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* odd 8 */

          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* odd 6 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* odd 7 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* odd 8 */

          "sb               %[st2],       11(%[dst])                   \n\t" /* odd 6 */
          "sb               %[st3],       13(%[dst])                   \n\t" /* odd 7 */
          "sb               %[st1],       15(%[dst])                   \n\t" /* odd 8 */

          : [qload1] "=&r"(qload1), [qload2] "=&r"(qload2),
            [qload3] "=&r"(qload3), [st1] "=&r"(st1), [st2] "=&r"(st2),
            [st3] "=&r"(st3), [p1] "=&r"(p1), [p2] "=&r"(p2), [p3] "=&r"(p3),
            [p4] "=&r"(p4), [p5] "=&r"(p5), [Temp1] "=&r"(Temp1),
            [Temp2] "=&r"(Temp2), [Temp3] "=&r"(Temp3)
          : [filter12] "r"(filter12), [filter34] "r"(filter34),
            [filter56] "r"(filter56), [filter78] "r"(filter78),
            [vector_64] "r"(vector_64), [cm] "r"(cm), [dst] "r"(dst),
            [src] "r"(src));

      src += 16;
      dst += 16;
    }

    /* Next row... */
    src_ptr += src_stride;
    dst_ptr += dst_stride;
  }
}

static void convolve_horiz_64_dspr2(const uint8_t *src_ptr, int32_t src_stride,
                                    uint8_t *dst_ptr, int32_t dst_stride,
                                    const int16_t *filter_x0, int32_t h) {
  int32_t y, c;
  const uint8_t *src;
  uint8_t *dst;
  uint8_t *cm = aom_ff_cropTbl;
  uint32_t vector_64 = 64;
  int32_t filter12, filter34, filter56, filter78;
  int32_t Temp1, Temp2, Temp3;
  uint32_t qload1, qload2, qload3;
  uint32_t p1, p2, p3, p4, p5;
  uint32_t st1, st2, st3;

  filter12 = ((const int32_t *)filter_x0)[0];
  filter34 = ((const int32_t *)filter_x0)[1];
  filter56 = ((const int32_t *)filter_x0)[2];
  filter78 = ((const int32_t *)filter_x0)[3];

  for (y = h; y--;) {
    src = src_ptr;
    dst = dst_ptr;

    /* prefetch data to cache memory */
    prefetch_load(src_ptr + src_stride);
    prefetch_load(src_ptr + src_stride + 32);
    prefetch_load(src_ptr + src_stride + 64);
    prefetch_store(dst_ptr + dst_stride);
    prefetch_store(dst_ptr + dst_stride + 32);

    for (c = 0; c < 4; c++) {
      __asm__ __volatile__(
          "ulw              %[qload1],    0(%[src])                    \n\t"
          "ulw              %[qload2],    4(%[src])                    \n\t"

          /* even 1. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* even 1 */
          "mthi             $zero,        $ac1                         \n\t"
          "mtlo             %[vector_64], $ac2                         \n\t" /* even 2 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload1]                    \n\t"
          "preceu.ph.qbl    %[p2],        %[qload1]                    \n\t"
          "preceu.ph.qbr    %[p3],        %[qload2]                    \n\t"
          "preceu.ph.qbl    %[p4],        %[qload2]                    \n\t"
          "ulw              %[qload3],    8(%[src])                    \n\t"
          "dpa.w.ph         $ac1,         %[p1],          %[filter12]  \n\t" /* even 1 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter34]  \n\t" /* even 1 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter56]  \n\t" /* even 1 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter78]  \n\t" /* even 1 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* even 1 */

          /* even 2. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* even 3 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload3]                    \n\t"
          "preceu.ph.qbl    %[p5],        %[qload3]                    \n\t"
          "ulw              %[qload1],    12(%[src])                   \n\t"
          "dpa.w.ph         $ac2,         %[p2],          %[filter12]  \n\t" /* even 1 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter34]  \n\t" /* even 1 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter56]  \n\t" /* even 1 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter78]  \n\t" /* even 1 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* even 1 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* even 1 */

          /* even 3. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* even 4 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbr    %[p2],        %[qload1]                    \n\t"
          "sb               %[st1],       0(%[dst])                    \n\t" /* even 1 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter12]  \n\t" /* even 3 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter34]  \n\t" /* even 3 */
          "dpa.w.ph         $ac3,         %[p1],          %[filter56]  \n\t" /* even 3 */
          "dpa.w.ph         $ac3,         %[p5],          %[filter78]  \n\t" /* even 3 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* even 3 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* even 1 */

          /* even 4. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* even 5 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbl    %[p3],        %[qload1]                    \n\t"
          "sb               %[st2],       2(%[dst])                    \n\t" /* even 1 */
          "ulw              %[qload2],    16(%[src])                   \n\t"
          "dpa.w.ph         $ac1,         %[p4],          %[filter12]  \n\t" /* even 4 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter34]  \n\t" /* even 4 */
          "dpa.w.ph         $ac1,         %[p5],          %[filter56]  \n\t" /* even 4 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter78]  \n\t" /* even 4 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* even 4 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* even 3 */

          /* even 5. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* even 6 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbr    %[p4],        %[qload2]                    \n\t"
          "sb               %[st3],       4(%[dst])                    \n\t" /* even 3 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter12]  \n\t" /* even 5 */
          "dpa.w.ph         $ac2,         %[p5],          %[filter34]  \n\t" /* even 5 */
          "dpa.w.ph         $ac2,         %[p2],          %[filter56]  \n\t" /* even 5 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter78]  \n\t" /* even 5 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* even 5 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* even 4 */

          /* even 6. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* even 7 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbl    %[p1],        %[qload2]                    \n\t"
          "sb               %[st1],       6(%[dst])                    \n\t" /* even 4 */
          "ulw              %[qload3],    20(%[src])                   \n\t"
          "dpa.w.ph         $ac3,         %[p5],          %[filter12]  \n\t" /* even 6 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter34]  \n\t" /* even 6 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter56]  \n\t" /* even 6 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter78]  \n\t" /* even 6 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* even 6 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* even 5 */

          /* even 7. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* even 8 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p5],        %[qload3]                    \n\t"
          "sb               %[st2],       8(%[dst])                    \n\t" /* even 5 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter12]  \n\t" /* even 7 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter34]  \n\t" /* even 7 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter56]  \n\t" /* even 7 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter78]  \n\t" /* even 7 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* even 7 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* even 6 */

          /* even 8. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* odd 1 */
          "mthi             $zero,        $ac3                         \n\t"
          "dpa.w.ph         $ac2,         %[p3],          %[filter12]  \n\t" /* even 8 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter34]  \n\t" /* even 8 */
          "sb               %[st3],       10(%[dst])                   \n\t" /* even 6 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter56]  \n\t" /* even 8 */
          "dpa.w.ph         $ac2,         %[p5],          %[filter78]  \n\t" /* even 8 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* even 8 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* even 7 */

          /* ODD pixels */
          "ulw              %[qload1],    1(%[src])                    \n\t"
          "ulw              %[qload2],    5(%[src])                    \n\t"

          /* odd 1. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* odd 2 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload1]                    \n\t"
          "preceu.ph.qbl    %[p2],        %[qload1]                    \n\t"
          "preceu.ph.qbr    %[p3],        %[qload2]                    \n\t"
          "preceu.ph.qbl    %[p4],        %[qload2]                    \n\t"
          "sb               %[st1],       12(%[dst])                   \n\t" /* even 7 */
          "ulw              %[qload3],    9(%[src])                    \n\t"
          "dpa.w.ph         $ac3,         %[p1],          %[filter12]  \n\t" /* odd 1 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter34]  \n\t" /* odd 1 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter56]  \n\t" /* odd 1 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter78]  \n\t" /* odd 1 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* odd 1 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* even 8 */

          /* odd 2. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* odd 3 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p1],        %[qload3]                    \n\t"
          "preceu.ph.qbl    %[p5],        %[qload3]                    \n\t"
          "sb               %[st2],       14(%[dst])                   \n\t" /* even 8 */
          "ulw              %[qload1],    13(%[src])                   \n\t"
          "dpa.w.ph         $ac1,         %[p2],          %[filter12]  \n\t" /* odd 2 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter34]  \n\t" /* odd 2 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter56]  \n\t" /* odd 2 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter78]  \n\t" /* odd 2 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* odd 2 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* odd 1 */

          /* odd 3. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* odd 4 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbr    %[p2],        %[qload1]                    \n\t"
          "sb               %[st3],       1(%[dst])                    \n\t" /* odd 1 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter12]  \n\t" /* odd 3 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter34]  \n\t" /* odd 3 */
          "dpa.w.ph         $ac2,         %[p1],          %[filter56]  \n\t" /* odd 3 */
          "dpa.w.ph         $ac2,         %[p5],          %[filter78]  \n\t" /* odd 3 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* odd 3 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* odd 2 */

          /* odd 4. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* odd 5 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbl    %[p3],        %[qload1]                    \n\t"
          "sb               %[st1],       3(%[dst])                    \n\t" /* odd 2 */
          "ulw              %[qload2],    17(%[src])                   \n\t"
          "dpa.w.ph         $ac3,         %[p4],          %[filter12]  \n\t" /* odd 4 */
          "dpa.w.ph         $ac3,         %[p1],          %[filter34]  \n\t" /* odd 4 */
          "dpa.w.ph         $ac3,         %[p5],          %[filter56]  \n\t" /* odd 4 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter78]  \n\t" /* odd 4 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* odd 4 */
          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* odd 3 */

          /* odd 5. pixel */
          "mtlo             %[vector_64], $ac2                         \n\t" /* odd 6 */
          "mthi             $zero,        $ac2                         \n\t"
          "preceu.ph.qbr    %[p4],        %[qload2]                    \n\t"
          "sb               %[st2],       5(%[dst])                    \n\t" /* odd 3 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter12]  \n\t" /* odd 5 */
          "dpa.w.ph         $ac1,         %[p5],          %[filter34]  \n\t" /* odd 5 */
          "dpa.w.ph         $ac1,         %[p2],          %[filter56]  \n\t" /* odd 5 */
          "dpa.w.ph         $ac1,         %[p3],          %[filter78]  \n\t" /* odd 5 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* odd 5 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* odd 4 */

          /* odd 6. pixel */
          "mtlo             %[vector_64], $ac3                         \n\t" /* odd 7 */
          "mthi             $zero,        $ac3                         \n\t"
          "preceu.ph.qbl    %[p1],        %[qload2]                    \n\t"
          "sb               %[st3],       7(%[dst])                    \n\t" /* odd 4 */
          "ulw              %[qload3],    21(%[src])                   \n\t"
          "dpa.w.ph         $ac2,         %[p5],          %[filter12]  \n\t" /* odd 6 */
          "dpa.w.ph         $ac2,         %[p2],          %[filter34]  \n\t" /* odd 6 */
          "dpa.w.ph         $ac2,         %[p3],          %[filter56]  \n\t" /* odd 6 */
          "dpa.w.ph         $ac2,         %[p4],          %[filter78]  \n\t" /* odd 6 */
          "extp             %[Temp2],     $ac2,           31           \n\t" /* odd 6 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* odd 5 */

          /* odd 7. pixel */
          "mtlo             %[vector_64], $ac1                         \n\t" /* odd 8 */
          "mthi             $zero,        $ac1                         \n\t"
          "preceu.ph.qbr    %[p5],        %[qload3]                    \n\t"
          "sb               %[st1],       9(%[dst])                    \n\t" /* odd 5 */
          "dpa.w.ph         $ac3,         %[p2],          %[filter12]  \n\t" /* odd 7 */
          "dpa.w.ph         $ac3,         %[p3],          %[filter34]  \n\t" /* odd 7 */
          "dpa.w.ph         $ac3,         %[p4],          %[filter56]  \n\t" /* odd 7 */
          "dpa.w.ph         $ac3,         %[p1],          %[filter78]  \n\t" /* odd 7 */
          "extp             %[Temp3],     $ac3,           31           \n\t" /* odd 7 */

          /* odd 8. pixel */
          "dpa.w.ph         $ac1,         %[p3],          %[filter12]  \n\t" /* odd 8 */
          "dpa.w.ph         $ac1,         %[p4],          %[filter34]  \n\t" /* odd 8 */
          "dpa.w.ph         $ac1,         %[p1],          %[filter56]  \n\t" /* odd 8 */
          "dpa.w.ph         $ac1,         %[p5],          %[filter78]  \n\t" /* odd 8 */
          "extp             %[Temp1],     $ac1,           31           \n\t" /* odd 8 */

          "lbux             %[st2],       %[Temp2](%[cm])              \n\t" /* odd 6 */
          "lbux             %[st3],       %[Temp3](%[cm])              \n\t" /* odd 7 */
          "lbux             %[st1],       %[Temp1](%[cm])              \n\t" /* odd 8 */

          "sb               %[st2],       11(%[dst])                   \n\t" /* odd 6 */
          "sb               %[st3],       13(%[dst])                   \n\t" /* odd 7 */
          "sb               %[st1],       15(%[dst])                   \n\t" /* odd 8 */

          : [qload1] "=&r"(qload1), [qload2] "=&r"(qload2),
            [qload3] "=&r"(qload3), [st1] "=&r"(st1), [st2] "=&r"(st2),
            [st3] "=&r"(st3), [p1] "=&r"(p1), [p2] "=&r"(p2), [p3] "=&r"(p3),
            [p4] "=&r"(p4), [p5] "=&r"(p5), [Temp1] "=&r"(Temp1),
            [Temp2] "=&r"(Temp2), [Temp3] "=&r"(Temp3)
          : [filter12] "r"(filter12), [filter34] "r"(filter34),
            [filter56] "r"(filter56), [filter78] "r"(filter78),
            [vector_64] "r"(vector_64), [cm] "r"(cm), [dst] "r"(dst),
            [src] "r"(src));

      src += 16;
      dst += 16;
    }

    /* Next row... */
    src_ptr += src_stride;
    dst_ptr += dst_stride;
  }
}

void aom_convolve8_horiz_dspr2(const uint8_t *src, ptrdiff_t src_stride,
                               uint8_t *dst, ptrdiff_t dst_stride,
                               const int16_t *filter_x, int x_step_q4,
                               const int16_t *filter_y, int y_step_q4, int w,
                               int h) {
  assert(x_step_q4 == 16);
  assert(((const int32_t *)filter_x)[1] != 0x800000);

  if (((const int32_t *)filter_x)[0] == 0) {
    aom_convolve2_horiz_dspr2(src, src_stride, dst, dst_stride, filter_x,
                              x_step_q4, filter_y, y_step_q4, w, h);
  } else {
    uint32_t pos = 38;

    prefetch_load((const uint8_t *)filter_x);
    src -= 3;

    /* bit positon for extract from acc */
    __asm__ __volatile__("wrdsp      %[pos],     1           \n\t"
                         :
                         : [pos] "r"(pos));

    /* prefetch data to cache memory */
    prefetch_load(src);
    prefetch_load(src + 32);
    prefetch_store(dst);

    switch (w) {
      case 4:
        convolve_horiz_4_dspr2(src, (int32_t)src_stride, dst,
                               (int32_t)dst_stride, filter_x, (int32_t)h);
        break;
      case 8:
        convolve_horiz_8_dspr2(src, (int32_t)src_stride, dst,
                               (int32_t)dst_stride, filter_x, (int32_t)h);
        break;
      case 16:
        convolve_horiz_16_dspr2(src, (int32_t)src_stride, dst,
                                (int32_t)dst_stride, filter_x, (int32_t)h, 1);
        break;
      case 32:
        convolve_horiz_16_dspr2(src, (int32_t)src_stride, dst,
                                (int32_t)dst_stride, filter_x, (int32_t)h, 2);
        break;
      case 64:
        prefetch_load(src + 64);
        prefetch_store(dst + 32);

        convolve_horiz_64_dspr2(src, (int32_t)src_stride, dst,
                                (int32_t)dst_stride, filter_x, (int32_t)h);
        break;
      default:
        aom_convolve8_horiz_c(src + 3, src_stride, dst, dst_stride, filter_x,
                              x_step_q4, filter_y, y_step_q4, w, h);
        break;
    }
  }
}
#endif