Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC -mthumb against -marm

I am working on performance optimizations of ARM C/C++ code, compiled with GCC. CPU is Tegra 3. As I know flags -mthumb means generating old 16-bit Thumb instructions. On different tests, I have 10-15% performance increase with -marm against -mthumb.

Is -mthumb used only for compatibility and for performance, while -marm is generally better? I am asking because android-cmake used -mthumb in Release mode and -marm in Debug. This is very confusing for me.

like image 275
exbluesbreaker Avatar asked Jun 16 '12 11:06

exbluesbreaker


1 Answers

Thumb is not the older instruction-set, but in fact the newer one. The current revision being Thumb-2, which is a mixed 16/32-bit instruction set. The Thumb1 instruction set was a compressed version of the original ARM instruction set. The CPU would fetch the the instruction, decompress it into ARM and then process it. These days (ARMv7 and above), Thumb-2 is preferred for everything but performance critical or system code. For example, GCC will by default generate Thumb2 for ARMv7 (Like your Tegra3), as the higher code density provided by the 16/32-bit ISA allows for better icache utilization. But this is something which is very hard to measure in a normal benchmark, because most benchmarks will fit into the L1 icache anyway.

For more information check the Wikipedia site: http://en.wikipedia.org/wiki/ARM_architecture#Thumb

like image 116
Nico Erfurth Avatar answered Oct 07 '22 01:10

Nico Erfurth