New safe CFLAGS optimization for the Intel I7 CPUs with GCC up to 4.7

If you have a new Intel core Core i3/i5/i7 CPUs, like for example:

$ grep -m1 -A3 "vendor_id" /proc/cpuinfo
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz

then the recent GCC version, starting with the version 4.7 brings a new support for optimization flags.

 $ gcc-config -l
 [1] x86_64-pc-linux-gnu-4.6.3
 [2] x86_64-pc-linux-gnu-4.7.2 *

For the IvyBridge chipset

  $ dmesg | grep Ivy
[    0.179101] Performance Events: PEBS fmt1+, 16-deep LBR, IvyBridge events, Intel PMU driver.
[    0.922097] pci 0000:00:00.0: Intel Ivybridge Chipset

a new march option can be used:

File: /etc/portage/make.conf
CFLAGS="-march=core-avx-i -O2 -pipe"

More Information can be found on Gentoo wiki and on the Intel pages.

Leave a comment