diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index 35c1db87d129d..3a3139db4a157 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -2997,6 +2997,9 @@ GenTree* Compiler::optVNBasedFoldConstExpr(BasicBlock* block, GenTree* parent, G } break; +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { simdmask_t value = vnStore->ConstantValue(vnCns); @@ -3008,7 +3011,7 @@ GenTree* Compiler::optVNBasedFoldConstExpr(BasicBlock* block, GenTree* parent, G break; } break; -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD case TYP_BYREF: diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index ec7c458bd7220..32d4d1e669d87 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -8225,6 +8225,9 @@ CORINFO_FIELD_HANDLE emitter::emitSimd64Const(simd64_t constValue) return emitComp->eeFindJitDataOffs(cnum); } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) CORINFO_FIELD_HANDLE emitter::emitSimdMaskConst(simdmask_t constValue) { unsigned cnsSize = 8; @@ -8240,7 +8243,7 @@ CORINFO_FIELD_HANDLE emitter::emitSimdMaskConst(simdmask_t constValue) UNATIVE_OFFSET cnum = emitDataConst(&constValue, cnsSize, cnsAlign, TYP_MASK); return emitComp->eeFindJitDataOffs(cnum); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD /***************************************************************************** diff --git a/src/coreclr/jit/emit.h b/src/coreclr/jit/emit.h index 1e50f64f2376b..88152601a7564 100644 --- a/src/coreclr/jit/emit.h +++ b/src/coreclr/jit/emit.h @@ -2525,8 +2525,11 @@ class emitter #if defined(TARGET_XARCH) CORINFO_FIELD_HANDLE emitSimd32Const(simd32_t constValue); CORINFO_FIELD_HANDLE emitSimd64Const(simd64_t constValue); - CORINFO_FIELD_HANDLE emitSimdMaskConst(simdmask_t constValue); #endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) + CORINFO_FIELD_HANDLE emitSimdMaskConst(simdmask_t constValue); +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD regNumber emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, GenTree* src); regNumber emitInsTernary(instruction ins, emitAttr attr, GenTree* dst, GenTree* src1, GenTree* src2); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 3f2ace8415866..713708f311fa8 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -3316,14 +3316,16 @@ unsigned Compiler::gtHashValue(GenTree* tree) switch (vecCon->TypeGet()) { #if defined(FEATURE_SIMD) -#if defined(TARGET_XARCH) +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { add = genTreeHashAdd(ulo32(add), vecCon->gtSimdVal.u32[1]); add = genTreeHashAdd(ulo32(add), vecCon->gtSimdVal.u32[0]); break; } +#endif // FEATURE_MASKED_HW_INTRINSICS +#if defined(TARGET_XARCH) case TYP_SIMD64: { add = genTreeHashAdd(ulo32(add), vecCon->gtSimdVal.u32[15]); @@ -12219,12 +12221,15 @@ void Compiler::gtDispConst(GenTree* tree) break; } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { printf("<0x%08x, 0x%08x>", vecCon->gtSimdVal.u32[0], vecCon->gtSimdVal.u32[1]); break; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS default: { diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 4092f40e7d2a6..a5188265beb89 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -6648,11 +6648,14 @@ struct GenTreeVecCon : public GenTree simd16_t gtSimd16Val; #if defined(TARGET_XARCH) - simd32_t gtSimd32Val; - simd64_t gtSimd64Val; - simdmask_t gtSimdMaskVal; + simd32_t gtSimd32Val; + simd64_t gtSimd64Val; #endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) + simdmask_t gtSimdMaskVal; +#endif // FEATURE_MASKED_HW_INTRINSICS + simd_t gtSimdVal; }; @@ -7075,11 +7078,14 @@ struct GenTreeVecCon : public GenTree return gtSimd64Val.IsAllBitsSet(); } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { return gtSimdMaskVal.IsAllBitsSet(); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: @@ -7129,11 +7135,14 @@ struct GenTreeVecCon : public GenTree return left->gtSimd64Val == right->gtSimd64Val; } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { return left->gtSimdMaskVal == right->gtSimdMaskVal; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: @@ -7178,11 +7187,14 @@ struct GenTreeVecCon : public GenTree return gtSimd64Val.IsZero(); } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { return gtSimdMaskVal.IsZero(); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: diff --git a/src/coreclr/jit/instr.cpp b/src/coreclr/jit/instr.cpp index 1ea14aaf6a38a..f8c05010f22c2 100644 --- a/src/coreclr/jit/instr.cpp +++ b/src/coreclr/jit/instr.cpp @@ -990,13 +990,16 @@ CodeGen::OperandDesc CodeGen::genOperandDesc(GenTree* op) return OperandDesc(emit->emitSimd64Const(constValue)); } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { simdmask_t constValue; memcpy(&constValue, &op->AsVecCon()->gtSimdVal, sizeof(simdmask_t)); return OperandDesc(emit->emitSimdMaskConst(constValue)); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: diff --git a/src/coreclr/jit/simd.h b/src/coreclr/jit/simd.h index 8364861cf09d4..72d710b4aea69 100644 --- a/src/coreclr/jit/simd.h +++ b/src/coreclr/jit/simd.h @@ -292,7 +292,9 @@ struct simd64_t } }; static_assert_no_msg(sizeof(simd64_t) == 64); +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) struct simdmask_t { union @@ -342,7 +344,9 @@ struct simdmask_t } }; static_assert_no_msg(sizeof(simdmask_t) == 8); +#endif // FEATURE_MASKED_HW_INTRINSICS +#if defined(TARGET_XARCH) typedef simd64_t simd_t; #else typedef simd16_t simd_t; diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 17b45702776c8..cb6bd6b1f6bf5 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -437,8 +437,10 @@ ValueNumStore::ValueNumStore(Compiler* comp, CompAllocator alloc) #if defined(TARGET_XARCH) , m_simd32CnsMap(nullptr) , m_simd64CnsMap(nullptr) - , m_simdMaskCnsMap(nullptr) #endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) + , m_simdMaskCnsMap(nullptr) +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD , m_VNFunc0Map(nullptr) , m_VNFunc1Map(nullptr) @@ -1711,13 +1713,15 @@ ValueNumStore::Chunk::Chunk(CompAllocator alloc, ValueNum* pNextBaseVN, var_type m_defs = new (alloc) Alloc::Type[ChunkSize]; break; } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { m_defs = new (alloc) Alloc::Type[ChunkSize]; break; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: @@ -1881,12 +1885,14 @@ ValueNum ValueNumStore::VNForSimd64Con(const simd64_t& cnsVal) { return VnForConst(cnsVal, GetSimd64CnsMap(), TYP_SIMD64); } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) ValueNum ValueNumStore::VNForSimdMaskCon(const simdmask_t& cnsVal) { return VnForConst(cnsVal, GetSimdMaskCnsMap(), TYP_MASK); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD ValueNum ValueNumStore::VNForGenericCon(var_types typ, uint8_t* cnsVal) @@ -1987,12 +1993,15 @@ ValueNum ValueNumStore::VNForGenericCon(var_types typ, uint8_t* cnsVal) READ_VALUE(simd64_t); return VNForSimd64Con(val); } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { READ_VALUE(simdmask_t); return VNForSimdMaskCon(val); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: unreached(); @@ -2106,12 +2115,14 @@ ValueNum ValueNumStore::VNZeroForType(var_types typ) { return VNForSimd64Con(simd64_t::Zero()); } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { return VNForSimdMaskCon(simdmask_t::Zero()); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD // These should be unreached. @@ -2201,12 +2212,14 @@ ValueNum ValueNumStore::VNAllBitsForType(var_types typ) { return VNForSimd64Con(simd64_t::AllBitsSet()); } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { return VNForSimdMaskCon(simdmask_t::AllBitsSet()); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD default: @@ -2319,11 +2332,14 @@ ValueNum ValueNumStore::VNBroadcastForSimdType(var_types simdType, var_types sim return VNForSimd64Con(result); } +#endif // TARGET_XARCH + +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { unreached(); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS default: { @@ -2390,12 +2406,14 @@ bool ValueNumStore::VNIsVectorNaN(var_types simdType, var_types simdBaseType, Va memcpy(&vector, &tmp, genTypeSize(simdType)); break; } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { unreached(); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS default: { @@ -3925,7 +3943,9 @@ simd64_t ValueNumStore::GetConstantSimd64(ValueNum argVN) return ConstantValue(argVN); } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) // Given a simdmask constant value number return its value as a simdmask. // simdmask_t ValueNumStore::GetConstantSimdMask(ValueNum argVN) @@ -3935,7 +3955,7 @@ simdmask_t ValueNumStore::GetConstantSimdMask(ValueNum argVN) return ConstantValue(argVN); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD // Compute the proper value number when the VNFunc has all constant arguments @@ -9486,14 +9506,16 @@ void ValueNumStore::vnDump(Compiler* comp, ValueNum vn, bool isPtr) cnsVal.u64[6], cnsVal.u64[7]); break; } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { simdmask_t cnsVal = GetConstantSimdMask(vn); printf("SimdMaskCns[0x%08x, 0x%08x]", cnsVal.u32[0], cnsVal.u32[1]); break; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD // These should be unreached. @@ -10934,7 +10956,9 @@ void Compiler::fgValueNumberTreeConst(GenTree* tree) tree->gtVNPair.SetBoth(vnStore->VNForSimd64Con(simd64Val)); break; } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) case TYP_MASK: { simdmask_t simdmaskVal; @@ -10943,7 +10967,7 @@ void Compiler::fgValueNumberTreeConst(GenTree* tree) tree->gtVNPair.SetBoth(vnStore->VNForSimdMaskCon(simdmaskVal)); break; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD case TYP_FLOAT: diff --git a/src/coreclr/jit/valuenum.h b/src/coreclr/jit/valuenum.h index 4df32b8096acd..ce33be31e19b0 100644 --- a/src/coreclr/jit/valuenum.h +++ b/src/coreclr/jit/valuenum.h @@ -367,10 +367,12 @@ class ValueNumStore simd12_t GetConstantSimd12(ValueNum argVN); simd16_t GetConstantSimd16(ValueNum argVN); #if defined(TARGET_XARCH) - simd32_t GetConstantSimd32(ValueNum argVN); - simd64_t GetConstantSimd64(ValueNum argVN); - simdmask_t GetConstantSimdMask(ValueNum argVN); + simd32_t GetConstantSimd32(ValueNum argVN); + simd64_t GetConstantSimd64(ValueNum argVN); #endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) + simdmask_t GetConstantSimdMask(ValueNum argVN); +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD private: @@ -453,8 +455,10 @@ class ValueNumStore #if defined(TARGET_XARCH) ValueNum VNForSimd32Con(const simd32_t& cnsVal); ValueNum VNForSimd64Con(const simd64_t& cnsVal); - ValueNum VNForSimdMaskCon(const simdmask_t& cnsVal); #endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) + ValueNum VNForSimdMaskCon(const simdmask_t& cnsVal); +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD ValueNum VNForGenericCon(var_types typ, uint8_t* cnsVal); @@ -1779,7 +1783,9 @@ class ValueNumStore } return m_simd64CnsMap; } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) struct SimdMaskPrimitiveKeyFuncs : public JitKeyFuncsDefEquals { static bool Equals(const simdmask_t& x, const simdmask_t& y) @@ -1808,7 +1814,7 @@ class ValueNumStore } return m_simdMaskCnsMap; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD template @@ -1991,14 +1997,16 @@ struct ValueNumStore::VarTypConv typedef simd64_t Type; typedef simd64_t Lang; }; +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) template <> struct ValueNumStore::VarTypConv { typedef simdmask_t Type; typedef simdmask_t Lang; }; -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD template <> @@ -2074,14 +2082,16 @@ FORCEINLINE simd64_t ValueNumStore::SafeGetConstantValue(Chunk* c, uns assert(c->m_typ == TYP_SIMD64); return reinterpret_cast::Lang*>(c->m_defs)[offset]; } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) template <> FORCEINLINE simdmask_t ValueNumStore::SafeGetConstantValue(Chunk* c, unsigned offset) { assert(c->m_typ == TYP_MASK); return reinterpret_cast::Lang*>(c->m_defs)[offset]; } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS template <> FORCEINLINE simd8_t ValueNumStore::ConstantValueInternal(ValueNum vn DEBUGARG(bool coerce)) @@ -2153,7 +2163,9 @@ FORCEINLINE simd64_t ValueNumStore::ConstantValueInternal(ValueNum vn return SafeGetConstantValue(c, offset); } +#endif // TARGET_XARCH +#if defined(FEATURE_MASKED_HW_INTRINSICS) template <> FORCEINLINE simdmask_t ValueNumStore::ConstantValueInternal(ValueNum vn DEBUGARG(bool coerce)) { @@ -2167,7 +2179,7 @@ FORCEINLINE simdmask_t ValueNumStore::ConstantValueInternal(ValueNum return SafeGetConstantValue(c, offset); } -#endif // TARGET_XARCH +#endif // FEATURE_MASKED_HW_INTRINSICS #endif // FEATURE_SIMD // Inline functions.