MIPS Compiler

I have just recently built a GCC cross-compiler for the MIPS architecture. I did this in order to do some comparison against the code generated by the LLVM MIPS compiler, which is marked as an experimental compiler. I picked up the C code for XTEA and compiled it using both compilers with optimisation turned on. The results are as follows:

GCC code size using MIPS1 instructions was 316 bytes long (79 words) while the LLVM one was 428 bytes long (107 words). In fact, the equivalent MIPS16 instruction is only 256 bytes long (128 words). So, the GCC output was far more efficient in terms of code size. However, I looked at the actual code output and found that LLVM had generated 19 no-ops (instructions that tell the processor to do nothing). These no-ops can be effectively removed to bring the code size down to 88 words, very close to the GCC output. Most of these no-ops were generated to avoid pipeline hazards. The number of load and stores generated by both compilers is the same, 8 loads and 4 stores each.

To me, this would seem to indicated that the LLVM compiler is fairly similar to the GCC in terms of code generation and should be useful in most cases.

Published by

Shawn Tan

Chip Doctor, Chartered/Professional Engineer, Entrepreneur, Law Graduate.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s