Using optimization remarks with Arm C/C++ Compiler

This short tutorial describes how to enable and use optimization remarks with Arm C/C++ Compiler.


Optimization remarks provide you with information about the choices made by the compiler. They can be used to see which code has been inlined or to understand why a loop has not been vectorized.

By default, Arm C/C++ Compiler prints compilation information to stderr. Using optimization remarks, optimization information is printed to the terminal or can be piped to an output file.

Enabling optimization remarks

To enable optimization remarks, pass the following -Rpass options to armclang:

Flag Description
 -Rpass=<regexp>  Request information about what Arm Compiler has optimized.
 -Rpass-analysis=<regexp>  Request information about what Arm Compiler has analyzed.
 -Rpass-missed=<regexp>  Request information about what Arm Compiler failed to optimize.

For each flag, replace <regexp> with an expression for the type of remarks you wish to view.

Recommended <regexp> queries are:

  • -Rpass=\(loop-vectorize\|inline\)
  • -Rpass-missed=\(loop-vectorize\|inline\)
  • -Rpass-analysis=\(loop-vectorize\|inline\)

where loop-vectorize will filter remarks regarding vectorized loops, and inline for remarks regarding inlining.

To search for all remarks, use the expression .*. However, use this expression with care because a lot of information may be printed depending on the size of your code and the level of optimization performed. 

C/C++ example using armclang

To pass the -Rpass and -Rpass-analysis flags to armclang, use:

armclang -O3 -Rpass=.* -Rpass-analysis=.* example.c

which can give the following example output in the terminal:

example.c:8:18: remark: hoisting zext 
[-Rpass=licm]        for (int i=0;i<K; i++)        ^ example.c:8:4: remark: vectorized loop (vectorization width: 4, interleaved count: 2)
[-Rpass=loop-vectorize]        for (int i=0;i<K; i++)        ^ example.c:7:1: remark: 28 instructions in function
[-Rpass-analysis=asm-printer]     void foo(int K) {     ^

Piping optimization remarks to a file

To pipe loop vectorization optimization remarks to a file called vecreport.txt, use:

armclang -O3 -Rpass=loop-vectorize -Rpass-analysis=loop-vectorize -Rpass-missed=loop-vectorize example.c 2> vecreport.txt

Related information