Compilers for Linux on Power optimization options

This article provides the recommended optimization settings for the XL, GCC, and Clang compilers for Linux on Power.

XL (xlc, xlC, xlf)

Get the latest releases:
GNU Compiler Collection (GCC) [1]

Get the latest release:
Clang

Get the latest release:
LLVM Download Page
Architecture
Generate instructions that run on POWER8 -mcpu=power8 (XLC default)
-qarch=pwr8 (XLF default)
-mcpu=power8 -target powerpcle-unknown-linux-gnu
-mcpu=pwr8
Generate instructions that run on POWER9 -mcpu=power9
-qarch=pwr9
-mcpu=power9 -target powerpcle-unknown-linux-gnu
-mcpu=pwr9
Optimization levels
Disable all optimizations -O0 -qnoopt (default) -O0 (default) -O0 (default)
Optimization levels -O
-O2
-O3
-O4
-O5[2]
-O or -O1
-O2
-O3
-Ofast
-O0
-01
-O2
-O3
-Os
Recommended optimization
(A good balance between run-time performance and compilation time)
Commercial code:
-O3 or -O3 -qipa
Technical computing/analytic:
-O3 or -Ofast
Commercial code:
-O3
Technical computing/analytic:
-Ofast -funroll-loops
-O3
Technical computing/analytic:
-O3 or -Ofast
Additional optimizations
Feedback directed optimization -qpdf1
-qpdf2
-fprofile-generate
-fprofile-use
-fprofile-generate
-fprofile-use
Interprocedural optimizations -qipa -flto -flto
OpenMP -qsmp=omp -fopenmp -fopenmp
Loop optimizations -qhot -fpeel-loops
-funroll-loops
-funroll-loops

[1] For the latest version of GCC for Linux on Power, plus optimized libraries that can be used with GCC or XL, see the Advance toolchain for Linux on Power pages.

[2] XL also accepts most GNU options