microcontroller
 

Reduce Code Size by up to 30% with CodeCompressor

Raisonance's unique post-link code optimization technology provides best results by applying optimizations using a complete view of all modules in large applications.

How does CodeCompressor work?

CodeCompressor is a complement to traditional optimizing compilers, which apply optimizations with a view of only one module at a time, thus limiting the scope of optimization. CodeCompressor acts after the linker and after all the intra-module optimizations have already been performed.

 

CodeCompressor acts in three passes, each of which can be automatically or manually controlled. Automatic controls are integrated in Ride, the Raisonance integrated development environment.

InLining

In this phase CodeCompressor looks for functions that are called only once in the application and moves these to the place where they are called, thus saving the CALL and RET instructions. This kind of optimization improves both the code size and the execution speed.

Factorization

In this phase CodeCompressor looks everywhere in the binary file for identical blocks of code and puts these in subroutines if they are big enough. This kind of optimization improves code size, but will slow down execution, so you might want to turn it off for time-critical functions of your application.

Local Optimizations (Peephole)

In this phase CodeCompressor rescans the entire code for the last time looking for local optimizations to implement, such as long jumps and call replacement with an equivalent shorter version, where possible. This kind of optimization improves both code size and execution speed.

CodeCompressor Benchmarks

 

The main purpose of CodeCompressor is to halp users reduce the memory size (code) required for their application. For this reason, all the benchmarks measure code size only. Compression rates vary largely from 0 (for a very small applications written in assembly) to >30% (for applications that are highly repetitive, for example using a lot of macros). Several factors come into play when estimating the compression rate users may get on specific applications, including:

  • Coding style
  • Language
  • The toolchain (mainly the compiler)
  • Architecture of the target device

For a typical application (some kb), written in C, a typical compression rate would be between 5% and 25%. The links below give some more indication on the results obtained on different tests and different architectures:

  • 8051 (Raisonance compiler)
  • XA (Raisonance compiler)
  • CoolRISC (with the GNU compiler)

Try CodeCompressor (download)

CodeCompressor is included in the demo or "evaluation" versions of all Raisonance toolchains for which it is available. Users can compress their code and simulate it. The only limitation is is that the compressed code can not be saved.

Microcontroller toolset downloads.

 
Compatibility

Because it requires strict interaction with many other tools in the toolchain, CodeCompressor works only with Raisonance tools. Note however that we have already successfully integrated at least one external Compiler (a port of GNU for the CoolRISC) for use with CodeCompressor.