Remove AVX/SSE transition penalties
authorLi Tian <litian2025@gmail.com>
Mon, 12 Dec 2016 03:13:28 +0000 (19:13 -0800)
committerLi Tian <litian2025@gmail.com>
Sun, 8 Jan 2017 20:44:12 +0000 (12:44 -0800)
commiteed8c183dd2eba8444c01dd6694b480a466703d8
tree79b3cbb05f28d98544bd2549dbb68d5a75c5fb99
parent21dced5f3607264e6fcc2c18af68ea0b1b95a1b5
Remove AVX/SSE transition penalties

There are two two kinds of transition penalties:
1.Transition from 256-bit AVX code to 128-bit legacy SSE code.
2.Transition from 128-bit legacy SSE code to either 128 or
256-bit AVX code. This only happens if there was a preceding
AVX256->legacy SSE transition penalty.

The primary goal is to remove the dotnet/coreclr#1 AVX to SSE transition penalty.

Added two emitter flags: contains256bitAVXInstruction indicates that
if the JIT method contains 256-bit AVX code, containsAVXInstruction
indicates that if the method contains 128-bit or 256-bit AVX code.

Issue VZEROUPPER in prolog if the method contains 128-bit or 256-bit
AVX code, to avoid legacy SSE to AVX transition penalty, this could
happen for reverse pinvoke situation. Issue VZEROUPPER in epilog
if the method contains 256-bit AVX code, to avoid AVX to legacy
SSE transition penalty.

To limite code size increase impact, we only issue VZEROUPPER before
PInvoke call on user defined function if the JIT method contains
256-bit AVX code, assuming user defined function contains legacy
SSE code. No need to issue VZEROUPPER after PInvoke call because dotnet/coreclr#2
SSE to AVX transition penalty won't happen since dotnet/coreclr#1 AVX to SSE
transition has been taken care of before the PInvoke call.

We measured ~3% to 1% performance gain on TechEmPower plaintext and
verified those VTune AVX/SSE events: OTHER_ASSISTS.AVX_TO_SSE and
OTHER_ASSISTS.SSE_TO_AVE have been reduced to 0.

Fix dotnet/coreclr#7240

move setContainsAVX flags to lower, refactor to a smaller method

refactor, fix typo in comments

fix format error

Commit migrated from https://github.com/dotnet/coreclr/commit/cc169eac6736693c4bdbd9f61ae821146252e4cb
src/coreclr/src/jit/codegen.h
src/coreclr/src/jit/codegencommon.cpp
src/coreclr/src/jit/codegenxarch.cpp
src/coreclr/src/jit/compiler.cpp
src/coreclr/src/jit/emitxarch.h
src/coreclr/src/jit/lower.h
src/coreclr/src/jit/lowerxarch.cpp