SEGGER Compiler — Optimizing C/C++
Generate optimized code for embedded systems.
Overview
The SEGGER Compiler is an optimized C/C++ compiler for Arm microcontrollers. Based on Clang, it offers a modern and flexible front end, which supports the latest C and C++ language features. The back end, which produces the binary objects for the target architecture has been optimized by SEGGER to generate fast and small Thumb-2 code for Cortex-M and Cortex-A processors. In combination with the SEGGER Linker, the SEGGER Assembler, and the SEGGER Runtime Library, it shapes a professional toolchain for any embedded application.
The SEGGER Compiler is directly integrated into Embedded Studio and can easily be used. As the front end is compatible to GCC and Clang, existing projects can be configured to use the SEGGER Compiler with just one option to be changed.
Key features
- Modern and flexible front end
- Back end optimized for performance and code size
- Optimized Thumb-2 code generation for Cortex-M and Cortex-A
- Fully compatible, easy to use
Performance
Size Optimization
The SEGGER Linker can tweak the code generation to produce small code for size optimization, while retaining good execution speed.
The following table shows the performance values of the compiler output with size optimization (-O2-sz).
Test Case | Code Size | Run Time | ||||
---|---|---|---|---|---|---|
SEGGER Compiler | Clang | GCC | SEGGER Compiler | Clang | GCC | |
CRC | 100.00% | 102.41% | 98.80% | 100.00% | 114.16% | 101.23% |
emCompress | 100.00% | 102.22% | 96.17% | 100.00% | 96.13% | 114.59% |
AES-CBC | 100.00% | 105.05% | 110.25% | 100.00% | 97.35% | 104.62% |
SHA-256 | 100.00% | 109.31% | 105.45% | 100.00% | 99.33% | 118.35% |
RSA Sign | 100.00% | 103.69% | 102.42% | 100.00% | 101.61% | 133.53% |
FS Test | 100.00% | 101.25% | 98.37% | 100.00% | 101.20% | 100.16% |
coremark | 100.00% | 102.52% | 100.36% | 100.00% | 98.00% | 99.70% |
Speed Optimization
The SEGGER Linker can optimize for speed while keeping small code size. Without extensive inlining and loop unrolling, it optimizes for faster applications.
The following table shows the performance values of the compilers with speed optimization (-O2-sp).
Test Case | Code Size | Run Time | ||||
---|---|---|---|---|---|---|
SEGGER Compiler | Clang | GCC | SEGGER Compiler | Clang | GCC | |
CRC | 100.00% | 102.41% | 98.80% | 100.00% | 114.16% | 101.23% |
emCompress | 100.00% | 102.22% | 96.17% | 100.00% | 96.13% | 114.59% |
AES-CBC | 100.00% | 105.05% | 110.25% | 100.00% | 97.35% | 104.62% |
SHA-256 | 100.00% | 109.31% | 105.45% | 100.00% | 99.33% | 118.35% |
RSA Sign | 100.00% | 103.69% | 102.42% | 100.00% | 101.61% | 133.53% |
FS Test | 100.00% | 101.25% | 98.37% | 100.00% | 101.20% | 100.16% |
coremark | 100.00% | 102.52% | 100.36% | 100.00% | 98.00% | 99.70% |
High Optimization
With highest optimization level, the SEGGER Compiler produces fastest code with advanced optimization and less focus on code size.
The following table shows the performance values of the compilers with highest optimization (-O3).
Test Case | Code Size | Run Time | ||||
---|---|---|---|---|---|---|
SEGGER Compiler | Clang | GCC | SEGGER Compiler | Clang | GCC | |
CRC | 100.00% | 101.81% | 36.20% | 100.00% | 101.44% | 108.79% |
emCompress | 100.00% | 102.93% | 66.22% | 100.00% | 109.11% | 96.10% |
AES-CBC | 100.00% | 111.87% | 95.02% | 100.00% | 106.38% | 123.52% |
SHA-256 | 100.00% | 108.41% | 94.60% | 100.00% | 104.04% | 107.39% |
RSA Sign | 100.00% | 108.07% | 74.98% | 100.00% | 101.54% | 117.14% |
FS Test | 100.00% | 101.26% | 91.64% | 100.00% | 99.90% | 91.26% |
coremark | 100.00% | 100.73% | 70.09% | 100.00% | 101.94% | 88.21% |