GCC 11 Compiler Performance Benchmarks With Various Optimization Levels, LTO

Written by Michael Larabel in Software on 14 June 2021 at 09:30 AM EDT. Page 1 of 4. 49 Comments.

Given the recent forum discussion stemming from the -O3 optimization level still too unsafe for the Linux kernel (in part due to older, buggy compilers) and some users wondering about the current -O2 versus -O3 compiler optimization level impact, here is a fresh round of reference benchmarks using GCC 11.1 on Fedora Workstation 33 looking at various optimization levels and optimizations tested on dozens of different application benchmarks to see the overall impact on performance.

With the recent optimization level discussions and not having done any thorough optimization level comparison tests and link-time optimization (LTO) testing of the recently released GCC 11, here is this Monday article for those interested in compiler optimizations.

The combination of CFLAGS/CXXFLAGS tested included:

-O0
-Og
-O1
-O2
-O2 -flto
-O2 -march=native
-O3
-O3 -flto
-O3 -march=native
-O3 -march=native -flto
-Ofast
-Ofast -march=native

Those dozen different CFLAGS/CXXFLAGS combinations were tested across 43 benchmarks looking at the performance on the resulting code each time.

This round of testing was carried out using an Intel Core i9 11900K "Rocket Lake" system with Fedora Workstation 33.

Related Articles