Skip to content

Random effect of Intel JCC Errata on micro optimizations #2405

Description

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions