mcpu vs march

Channagoud ckadabi@codeaurora.org
Fri Aug 9 16:38:00 GMT 2013


On 8/9/2013 4:32 AM, Kyrylo Tkachov wrote:
>> Hi,
>> I wanted to understand the difference of using march vs mcpu as argument
>> to gcc.
>> I am compiling my code for a cortex-A8 CPU,  what would be better to use:
>>
>> -mcpu=cortex-a8 or -march=armv7-a
> -mcpu=cortex-a8 will perform specific optimisations for the Cortex-A8 such as
> instruction scheduling and will produce better performing code on that core.
> -march=armv7-a just selects the ARMv7-a architecture which tells the compiler
> that it can use the instructions in ARMv7-a, but it will not perform any
> core-specific performance tuning.
>
> If you know that you'll be running your code on a Cortex-A8 you should specify
> -mcpu=cortex-a8, it also automatically implies -march=armv7-a.
>
> For more information on the options available for ARM you can look at:
> http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
>
> HTH,
> Kyrill
>
>> Thanks,
>> Channa
Hi Kyrill,
Thanks for the info.

Yes thats understood, but my concern is with respect to differences in instructions when the code is compiled. For eg: if I use armv7-a as -march & my cpu is cortex-a5 would it be possible that the code would compile fine but might give undefined instruction at some point if the compiler generated code has some instruction which is not supported on cortex-a5?

>

>
>



More information about the Gcc-help mailing list