@@ -10445,7 +10445,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
10445
10445
int size = (int)genTypeSize(tree->TypeGet());
10446
10446
const int maxElementSize = sizeof(simd_t);
10447
10447
10448
- if ((varTypeIsSIMD( tree) || varTypeIsIntegral(tree) || varTypeIsFloating(tree) || tree ->TypeIs(TYP_REF) ) &&
10448
+ if (! tree->TypeIs(TYP_BYREF, TYP_STRUCT ) &&
10449
10449
GetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &byteOffset, &fieldSeq))
10450
10450
{
10451
10451
CORINFO_FIELD_HANDLE fieldHandle = fieldSeq->GetFieldHandle();
@@ -10464,7 +10464,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
10464
10464
}
10465
10465
}
10466
10466
}
10467
- else if ((varTypeIsSIMD( tree) || varTypeIsIntegral(tree) || varTypeIsFloating(tree) ) &&
10467
+ else if (! tree->TypeIs(TYP_REF, TYP_BYREF, TYP_STRUCT ) &&
10468
10468
GetObjectHandleAndOffset(vnStore, tree->gtGetOp1(), &byteOffset, &obj))
10469
10469
{
10470
10470
// See if we can fold IND(ADD(FrozenObj, CNS)) to a constant
@@ -10754,12 +10754,18 @@ void Compiler::fgValueNumberTree(GenTree* tree)
10754
10754
10755
10755
if (!returnsTypeHandle)
10756
10756
{
10757
- // Indirections off of addresses for boxed statics represent bases for
10758
- // the address of the static itself. Here we will use "nullptr" for the
10759
- // field sequence and assume the actual static field will be appended to
10760
- // it later, as part of numbering the method table pointer offset addition.
10761
- if (addr->IsIconHandle(GTF_ICON_STATIC_BOX_PTR))
10757
+ // TYP_REF check to improve TP since we mostly target invariant loads of
10758
+ // frozen objects here
10759
+ if (addr->TypeIs(TYP_REF) && fgValueNumberConstLoad(tree->AsIndir()))
10762
10760
{
10761
+ // VN is assigned inside fgValueNumberConstLoad
10762
+ }
10763
+ else if (addr->IsIconHandle(GTF_ICON_STATIC_BOX_PTR))
10764
+ {
10765
+ // Indirections off of addresses for boxed statics represent bases for
10766
+ // the address of the static itself. Here we will use "nullptr" for the
10767
+ // field sequence and assume the actual static field will be appended to
10768
+ // it later, as part of numbering the method table pointer offset addition.
10763
10769
assert(addrNvnp.BothEqual() && (addrXvnp == vnStore->VNPForEmptyExcSet()));
10764
10770
ValueNum boxAddrVN = addrNvnp.GetLiberal();
10765
10771
ValueNum fieldSeqVN = vnStore->VNForFieldSeq(nullptr);
0 commit comments