https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57952
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to mmokrejs from comment #5) > (In reply to Jakub Jelinek from comment #4) > > > As for #c2/#c3, GCC 4.9 is not supported anymore and the dumps are too large > > to find out what exactly you mean by efficient and not efficient, both the > > ICC and GCC generated assemblies use both %ymm and %xmm registers depending > > on what exactly the need. > > "gcc -march=native" or "g++ march=native" do not insert a single instructing > using ymm registers unless -O3 is used. > > $ gcc -O3 -march=native -mavx2 stream.c ; objdump -d a.out | grep ymm | wc > -l > 63 > $ gcc -O2 -march=native -mavx2 stream.c ; objdump -d a.out | grep ymm | wc > -l > 0 > $ gcc -O2 -march=native stream.c ; objdump -d a.out | grep ymm | wc -l > 0 > $ gcc -O3 -march=native stream.c ; objdump -d a.out | grep ymm | wc -l > 63 > $ Of course, vectorization is only enabled by default for -O3/-Ofast, not at -O2, for vectorization at -O2 you need to use -O2 -ftree-vectorize.
