[cfe-dev] Option -mtune
Peter Smith via cfe-dev
cfe-dev at lists.llvm.org
Mon Apr 20 09:19:15 PDT 2020
> My naïve opinions FWIW:
> - Personally I have never understood the difference between -target, -march, -mcpu, and -mtune (particularly -march and -mtune).
> There are a lot of blog posts out there (e.g. https://lemire.me/blog/2018/07/25/it-is-more-complicated-than-i-thought-mtune-march-in-gcc/
> http://sdf.org/~riley/blog/2014/10/30/march-mtune/ ) indicating that I'm not alone. (Anyone got a really good resource on this topic?)
I haven't got a good reference in documentation unfortunately. The model our GCC team for Arm and AArch64 use (not sure if this applies to other Targets) is:
-mcpu=<cpu> == -march=<architecture CPU uses> -mtune=<cpu> where the mtune does not affect compatibility with architecture such as use of instructions, it could affect the scheduling model.
The reason for separating them is that you can in theory optimise code for running on a particular CPU but still have it be compatible with earlier CPUs of an earlier architecture. For example (sorry I only know Arm off the top of my head) -march=armv8-a -mtune=cortex-a76 . This would in GCC produce code optimised for cortex-a76, but would be compatible with other Arm processors that supported v8.0 (Cortex-A76 is v8.2).
Hope this helps, and hope I have that right.
More information about the cfe-dev