This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

neon 代码比C代码效率为啥比理论值相差这么大?

尝试翻译一段 图片镜像的代码,neon优化的代码运行时间,只有C代码的一半,但远低于loop循环计算出来的理论值,为什么会有这么大落差??

C代码:

void C_Nv21YSelfMirror(char* output,char * input,int width,int height)

{
        int i,j=0;

for(j=0; j<height;j++){

int index = j*width;

for(i=0;i<width;i++)
{
    *(output+index+i) = *(input+index+width-i-1);
}
}

}

neon代码:

;------------------------------------------------------
; # r0: Ptr to destination data
; # r1: Ptr to source data
; # r2: width count:
; # r3: height count:
Nv21YSelfMirror
          push {R0-R10,LR}
          mov r9,#0 ;i
          mov r10,#0 ;j
          BIC r2,r2,#0x0f ;width /16
mirror_y_lpj
          MLA R6,R10,R2,R1 ;int index = j*width + input_data;
          mov r4,r2 ;width
mirror_y_lpi
          subs r4,r4,#32 ;-32
          add r7,r6,r4 ;0st in_line
          vld1.32 {d0,d1,d2,d3},[r7]
          vrev64.8 d7,d0
         vrev64.8 d6,d1
          vrev64.8 d5,d2
         vrev64.8 d4,d3
         vst1.32 {d4,d5,d6,d7},[r0]!
bne mirror_y_lpi
        add r10,#01
        cmp r10,r3 ;j<height
        blo mirror_y_lpj
mirror_y_ret
         pop {R0-R10,PC}