viability to turn on -mavx / -mavx2 by default
Christian Krause
kizkizzbangbang@googlemail.com
Fri Feb 13 09:55:00 GMT 2015
Hello,
I have an "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz" (/proc/cpuinfo),
which is haswell architecture and includes all of the following flags:
sse sse2 ssse3 sse4_1 sse4_2 avx avx2
I'm usually compiling with these flags for optimization:
CFLAGS="-march=native -mfpmath=sse -O2"
CXXFLAGS="-march=native -mfpmath=sse -O2"
Now to my questions:
1. Since I have avx and avx2, is it viable to add -mavx / -mavx2 to the
above-mentioned flags to improve overall optimization? Does
-march=native enable these automatically?
2. Would adding these flags improve performance in all / most cases?
Are there cases where adding -mavx / -mavx2 backfires in terms of e.g.
performance?
3. Are these flags worth something, even if the code does not
explicitly use any avx/2 instructions?
4. As of the 4.9.2 man page I quote
> GCC depresses SSEx instructions when -mavx is used. Instead,
> it generates new AVX instructions or AVX equivalence for all
> SSEx instructions when needed.
What happens with -mfpmath=sse when -mavx / -mavx2 is enabled? Or
does this mean only the -msse* flags are depressed?
Since -msse2avx is turned on by -mavx automatically are
-mfpmath=sse instructions also encoded with VEX prefix? Would it not
make sense to add an option to have -mpfmath=avx?
5. If I have both avx and avx2, will -mavx2 switch on -mavx
automatically? (this is not covered by the man page)
To answer some of my questions myself, I ran (see output attached):
gcc -march=native -mfpmath=sse -O2 -Q --help=target -v
The output shows, that -mavx and -mavx2 are turned on by default with
-march=native and my haswell architecture. However, -msse2avx is still
disabled. Shouldn't this be enabled as well since -mavx is enabled? Is
this a bug?
Best Regards
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc.log
Type: text/x-log
Size: 8223 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20150213/991fb622/attachment.bin>
More information about the Gcc-help
mailing list