ARM NOEN vfmaq_laneq_f32与vextq_f32指令例子

vfmaq_laneq_f32是乘法运算相关指令,vextq_f32是取数据相关指令。具体功能用文字描述比较麻烦,直接看个列子一下就懂了,所以在这里记录下来。

    float32x4_t sum = vdupq_n_f32(0); //sum={0,0,0,0}
    float _a[] = {1,2,3,4}, _b[] = {5,6,7,8} ;
    float32x4_t a = vld1q_f32(_a), b = vld1q_f32(_b);
    //sum1={5,10,15,20}
    float32x4_t sum1 = vfmaq_laneq_f32(sum, a, b, 0); 
    //sum2={5,10,15,20}+{6,12,18,24} = {11,22,33,44}
    float32x4_t sum2 = vfmaq_laneq_f32(sum1, a, b, 1); 
    //sum3={11,22,33,44}+{7,14,21,28} = {18,36,54,72}
    float32x4_t sum3 = vfmaq_laneq_f32(sum2, a, b, 2);

    float32x4_t r1 = vextq_f32(a,b,1); //r1={2,3,4,5}
    float32x4_t r2 = vextq_f32(a,b,2); //r2={3,4,5,6}
    float32x4_t r3 = vextq_f32(a,b,3); //r3={4,5,6,7}

Reference:
http://blog.csdn.net/may0324/article/details/72847800
https://developer.arm.com/technologies/neon/intrinsics

你可能感兴趣的:(C语言,vfmaq-lane,vextq-f32,arm-neon)