<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:12.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Please let me know if you have ideas on how to make this code faster.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">I tried to remove the stall by fetching more memory earlier, still no change in performance:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">// void scale2D_64to32(pixel* dst, const pixel* src, intptr_t stride)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">function x265_scale2D_64to32_neon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> mov w12, #15<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v0.16b-v3.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v4.16b-v7.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">.loop_scale2D:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> sub w12, w12, #1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v20.16b-v23.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v24.16b-v27.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v0, v1, v2, v3, v4, v5, v6, v7<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v0.16b-v3.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v4.16b-v7.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v20, v21, v22, v23, v24, v25, v26, v27<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> cbnz w12, .loop_scale2D<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v20.16b-v23.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ld1 {v24.16b-v27.16b}, [x1], x2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v0, v1, v2, v3, v4, v5, v6, v7<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> scale2D_1 v20, v21, v22, v23, v24, v25, v26, v27<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> ret<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">endfunc<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">.macro scale2D_1 v0, v1, v2, v3, v4, v5, v6, v7<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v0\().8h, \v0\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v1\().8h, \v1\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v2\().8h, \v2\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v3\().8h, \v3\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v4\().8h, \v4\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v5\().8h, \v5\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v6\().8h, \v6\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uaddlp \v7\().8h, \v7\().16b<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v0\().8h, \v0\().8h, \v4\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v1\().8h, \v1\().8h, \v5\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v2\().8h, \v2\().8h, \v6\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> add \v3\().8h, \v3\().8h, \v7\().8h<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn \v0\().8b, \v0\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn2 \v0\().16b, \v1\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn \v1\().8b, \v2\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> uqrshrn2 \v1\().16b, \v3\().8h, #2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"> st1 {\v0\().16b-\v1\().16b}, [x0], #32<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">.endm<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">The only change that I did is to further optimize for code size by re-rolling the loop that was unrolled 2x.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">No change in performance, and 2x smaller code.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Sebastian<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
</div>
</body>
</html>