I encountered an issue in optimizing vector_algorithm.cpp.
Suddenly with otherwise good optimizations I run into bad branching pattern that is affected by Intel JCC erratum. The impact matters up to reversing the effect of the optimization. And just random NOPs can make the optimization great again, as the issue is triggered by a bad alignment of branching instructions.
The compiler has the flag /QIntel-jcc-erratum. If I add it to CMakeFile.txt, the optimizations start behaving predictable.
I'm worried that this flag may impact other CPUs though, specifically older AMD CPUs, or Atom CPUs.
Igor Zhukov (@fsb4000) confirmed that enabling /QIntel-jcc-erratum makes terrible perf on AMD FX 8300.
I can try to make vector_algorithm.cpp into two translation units, one is compiled with /QIntel-jcc-erratum and the other without, and that each function would branch into the /QIntel-jcc-erratum translation unit in case of running on the affected CPU. This seems to be the best option, but it slightly impact binary size, and introduces a lot of complexity.
What can we do here?
See the table in #2386 for example of the results. Note that enabling /QIntel-jcc-erratum both makes results better, and avoid unpredictable variations!
I encountered an issue in optimizing
vector_algorithm.cpp.Suddenly with otherwise good optimizations I run into bad branching pattern that is affected by Intel JCC erratum. The impact matters up to reversing the effect of the optimization. And just random NOPs can make the optimization great again, as the issue is triggered by a bad alignment of branching instructions.
The compiler has the flag
/QIntel-jcc-erratum. If I add it toCMakeFile.txt, the optimizations start behaving predictable.I'm worried that this flag may impact other CPUs though, specifically older AMD CPUs, or Atom CPUs.
Igor Zhukov (@fsb4000) confirmed that enabling
/QIntel-jcc-erratummakes terrible perf on AMD FX 8300.I can try to make
vector_algorithm.cppinto two translation units, one is compiled with/QIntel-jcc-erratumand the other without, and that each function would branch into the/QIntel-jcc-erratumtranslation unit in case of running on the affected CPU. This seems to be the best option, but it slightly impact binary size, and introduces a lot of complexity.What can we do here?
See the table in #2386 for example of the results. Note that enabling
/QIntel-jcc-erratumboth makes results better, and avoid unpredictable variations!