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

Can keil compiler translate C code into SIMD instructions(ARMv7-m)


When we write such code as following, can keil compiler automaticly translate it into SIMD STM.

  do{

          *p++ = 1;

           *p++ = 1;

           *p++ = 1;

           *p++ = 1;

           *p++ = 1;

           *p++ = 1;

           *p++ = 1;

           *p++ = 1;

     }while( i-- );

We write code like this expecting STM can be used to do some optimization.

If the compiler can do this, what the option it need? I think this is not the default behaviour.

Parents
  • Hi Zhiyang,

    Yes, but there is a distinction between a multiple store operation (STM) and a multiple data operation (SIMD).

    While you can use an STM to store many values subsequently, which in general will take N+1 cycles, SIMD performs operations on multiple data within the same clock cycle.

    One way to take advantage of SIMD is by using intrinsics. Consider the following 16 bit pointers:

    void function(  q15_t * pSrcA,  q15_t * pSrcB,  q15_t * pDst) {


    *pDst++ = (q15_t) __QADD16(*pSrcA++, *pSrcB++);


    }

    The piece of code above translates into a SIMD addition of two 16 bit registers at once.

    Cheers,

Reply
  • Hi Zhiyang,

    Yes, but there is a distinction between a multiple store operation (STM) and a multiple data operation (SIMD).

    While you can use an STM to store many values subsequently, which in general will take N+1 cycles, SIMD performs operations on multiple data within the same clock cycle.

    One way to take advantage of SIMD is by using intrinsics. Consider the following 16 bit pointers:

    void function(  q15_t * pSrcA,  q15_t * pSrcB,  q15_t * pDst) {


    *pDst++ = (q15_t) __QADD16(*pSrcA++, *pSrcB++);


    }

    The piece of code above translates into a SIMD addition of two 16 bit registers at once.

    Cheers,

Children