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 Zhi Yang,

    Yes, the Keil compiler will use the STM instruction automatically, when appropriate.  I have seen this instruction when looking at the intermediate ASM output of the compiler, and it is often used for stack operations.  My understanding is that on the M4 the STM instruction saves only on code space but does not reduce the cycle count.  N back-to-back stores takes N+1 instructions, and this holds true of individual store instructions are used or a single STM.

Reply
  • HI Zhi Yang,

    Yes, the Keil compiler will use the STM instruction automatically, when appropriate.  I have seen this instruction when looking at the intermediate ASM output of the compiler, and it is often used for stack operations.  My understanding is that on the M4 the STM instruction saves only on code space but does not reduce the cycle count.  N back-to-back stores takes N+1 instructions, and this holds true of individual store instructions are used or a single STM.

Children
No data