@@ -1814,7 +1814,12 @@ ValueNum ValueNumStore::VNZeroForType(var_types typ)
18141814 case TYP_SIMD12:
18151815 case TYP_SIMD16:
18161816 case TYP_SIMD32:
1817- return VNForLongCon (0 );
1817+ // We do not have the base type - a "fake" one will have to do. Note that we cannot
1818+ // use the HWIntrinsic "get_Zero" VNFunc here. This is because they only represent
1819+ // "fully zeroed" vectors, and here we may be loading one from memory, leaving upper
1820+ // bits undefined. So using "SIMD_Init" is "the next best thing", so to speak, and
1821+ // TYP_FLOAT is one of the more popular base types, so that's why we use it here.
1822+ return VNForFunc (typ, VNF_SIMD_Init, VNForFloatCon (0 ), VNForSimdType (genTypeSize (typ), TYP_FLOAT));
18181823#endif // FEATURE_SIMD
18191824
18201825 // These should be unreached.
@@ -1860,6 +1865,17 @@ ValueNum ValueNumStore::VNOneForType(var_types typ)
18601865 }
18611866}
18621867
1868+ #ifdef FEATURE_SIMD
1869+ ValueNum ValueNumStore::VNForSimdType (unsigned simdSize, var_types simdBaseType)
1870+ {
1871+ ValueNum baseTypeVN = VNForIntCon (INT32 (simdBaseType));
1872+ ValueNum sizeVN = VNForIntCon (simdSize);
1873+ ValueNum simdTypeVN = VNForFunc (TYP_REF, VNF_SimdType, sizeVN, baseTypeVN);
1874+
1875+ return simdTypeVN;
1876+ }
1877+ #endif // FEATURE_SIMD
1878+
18631879class Object * ValueNumStore::s_specialRefConsts[] = {nullptr , nullptr , nullptr };
18641880
18651881// ----------------------------------------------------------------------------------------
@@ -9510,9 +9526,7 @@ void Compiler::fgValueNumberSimd(GenTree* tree)
95109526
95119527 if (encodeResultType)
95129528 {
9513- ValueNum vnSize = vnStore->VNForIntCon (simdNode->GetSimdSize ());
9514- ValueNum vnBaseType = vnStore->VNForIntCon (INT32 (simdNode->GetSimdBaseType ()));
9515- ValueNum simdTypeVN = vnStore->VNForFunc (TYP_REF, VNF_SimdType, vnSize, vnBaseType);
9529+ ValueNum simdTypeVN = vnStore->VNForSimdType (simdNode->GetSimdSize (), simdNode->GetSimdBaseType ());
95169530 resvnp.SetBoth (simdTypeVN);
95179531
95189532#ifdef DEBUG
@@ -9627,9 +9641,8 @@ void Compiler::fgValueNumberHWIntrinsic(GenTree* tree)
96279641
96289642 if (encodeResultType)
96299643 {
9630- ValueNum vnSize = vnStore->VNForIntCon (hwIntrinsicNode->GetSimdSize ());
9631- ValueNum vnBaseType = vnStore->VNForIntCon (INT32 (hwIntrinsicNode->GetSimdBaseType ()));
9632- ValueNum simdTypeVN = vnStore->VNForFunc (TYP_REF, VNF_SimdType, vnSize, vnBaseType);
9644+ ValueNum simdTypeVN =
9645+ vnStore->VNForSimdType (hwIntrinsicNode->GetSimdSize (), hwIntrinsicNode->GetSimdBaseType ());
96339646 resvnp.SetBoth (simdTypeVN);
96349647
96359648#ifdef DEBUG
0 commit comments