Preventing GCC from automatically using AVX and FMA instructions when compiled with -mavx and -mfma

前端 未结 2 756
星月不相逢
星月不相逢 2020-12-03 06:01

How can I disable auto-vectorization with AVX and FMA instructions? I would still prefer the compiler to employ SSE and SSE2 automatically, but not FMA and AVX.

My c

2条回答
  •  不思量自难忘°
    2020-12-03 06:59

    You will need to separate the code that uses AVX into a separate compile unit (in other words, a separate .cpp file), and compile only that with -mfma or whatever options you want. Normally, gcc will use -march=native, so it will compile for "your processor", and if you want generic code, you will need to use -march=x86_64 or -march=core2, or something like that.

提交回复
热议问题