Add ValueNumbering support for GT_SIMD and GT_HWINTRINSIC tree nodes (#31834)
authorBrian Sullivan <briansul@microsoft.com>
Wed, 26 Feb 2020 23:28:29 +0000 (15:28 -0800)
committerGitHub <noreply@github.com>
Wed, 26 Feb 2020 23:28:29 +0000 (15:28 -0800)
commit4ef3cc68ccdf88af9bb39a491032b68ddf7f38ae
tree5656172bdc13a146760a6eb400003429f82629ac
parent6587f82f58317752b02478990c8b36612d4daa4f
Add ValueNumbering support for GT_SIMD and GT_HWINTRINSIC tree nodes (#31834)

* Added ValueNumbering support for GT_SIMD and GT_HWINTRINSIC tree nodes

* Allow SIMD and HW Intrinsics to be CSE candidates

* Correctness fix for optAssertionPropMain
  - Zero out the bbAssertionIn values, as these can be referenced in RangeCheck::MergeAssertion
    and this is shared state with the CSE phase: bbCseIn

* Improve the VNFOA_ArityMask

* Update to use the new TARGET macros

* Include node type when value numbering SIMDIntrinsicInit
Mutate the gloabl heap when performing a HW_INTRINSIC memory store operation
Printing of SIMD constants only support 0

* Disable CSE's for some special HW_INTRINSIC categories

* Code review feedback

* Record csdStructHnd; // The class handle, currently needed to create a SIMD LclVar in PerformCSE

* Instead of asserting on a struct handle mismatch, we record it in csdStructHndMismatch and avoid making the candidate into a CSE

* Fix the JITDUMP messages to print the CseIndex

* add check for (newElemStructHnd != NO_CLASS_HANDLE)

* Additional checks for SIMD struct types when setting csdStructHnd
Added Mismatched Struct Handle assert in ConsiderCandidates

* fix GenTreeSIMD::OperIsMemoryLoad for ARM64
Removed ismatched Struct Handle assert

* Fix the printing of BitSets on Linux, change the printf format specifier

* Added check for simdNode->OperIsMemoryLoad()) to fgValueNumberSimd
Added bool OperIsMemoryLoad() to GenTreeSIMD, returns true for SIMDIntrinsicInitArray
Added valuenumfuncs.h to src/coreclr/src/jit/CMakeLists.txt

* Avoid calling gtGetStructHandleIfPresent to set csdStructHnd when we have a GT_IND node

* Fix check for (newElemStructHnd != hashDsc->csdStructHnd)

* added extra value number argument VNF_SimdType for Most SIMD operations
added VNF_SimdType // A value number function to compose a SIMD type
added vnDumpSimdType

* Added bool methods vnEncodesResultTypeForSIMDIntrinsic and vnEncodesResultTypeForHWIntrinsic
these return true when a SIMD or HW Instrinsic will use an extra arg to record the result type during value numbering
Changes the ValueNumFuncDef to set the arity to zero when a -1 value is passed in
Updated InitValueNumStoreStatics to fixup the arity of SIMD or HW Instrinsic that have an extra arg to record the result type
Allow a type mismatchj when we have a GT_BLK as the lhs of an assignment, as it is used to zero out Simd structs

* Fix for SIMD_WidenLo arg count

* fix typo

* Fix x86 build breaks
Fix SIMD_WidenHi

* Added method header comment for vnEncodesResultTypeForHWIntrinsic
Added & VNFOA_ArityMask when assigning to vnfOpAttribs[]

* Codereview feedback and some more comments

* fix typo

* Moved the code that sets the arg count for the three SIMD intrinsics

* clang-format

* Adjust CSE for SIMD types that are live across a call

* Proposed fix for #32085

* Revert "Proposed fix for #32085"

This reverts commit 169c24eeafb072a79ffbdb2d1d36960ebc0c17b4.

* Added better comments for optcse SIMD caller saved register heuristics

* Added CONFIG_INTEGER: JitDisableSimdVN,
   Default 0, ValueNumbering of SIMD nodes and HW Intrinsic nodes enabled
   If 1, then disable ValueNumbering of SIMD nodes
   If 2, then disable ValueNumbering of HW Intrinsic nodes
   If 3, disable both SIMD and HW Intrinsic nodes

* Moved JitDisableSimdVN from DEBUG to RETAIL
14 files changed:
src/coreclr/src/jit/CMakeLists.txt
src/coreclr/src/jit/assertionprop.cpp
src/coreclr/src/jit/bitsetasshortlong.h
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/gentree.cpp
src/coreclr/src/jit/gentree.h
src/coreclr/src/jit/hwintrinsic.cpp
src/coreclr/src/jit/hwintrinsiclistxarch.h
src/coreclr/src/jit/jitconfigvalues.h
src/coreclr/src/jit/optcse.cpp
src/coreclr/src/jit/simd.cpp
src/coreclr/src/jit/valuenum.cpp
src/coreclr/src/jit/valuenum.h
src/coreclr/src/jit/valuenumfuncs.h