Skip to content

Commit 8995217

Browse files
authored
Run fgValueNumberConstLoad for invariant loads (#86154)
1 parent 4c0f2e7 commit 8995217

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/coreclr/jit/valuenum.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10445,7 +10445,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
1044510445
int size = (int)genTypeSize(tree->TypeGet());
1044610446
const int maxElementSize = sizeof(simd_t);
1044710447

10448-
if ((varTypeIsSIMD(tree) || varTypeIsIntegral(tree) || varTypeIsFloating(tree) || tree->TypeIs(TYP_REF)) &&
10448+
if (!tree->TypeIs(TYP_BYREF, TYP_STRUCT) &&
1044910449
GetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &byteOffset, &fieldSeq))
1045010450
{
1045110451
CORINFO_FIELD_HANDLE fieldHandle = fieldSeq->GetFieldHandle();
@@ -10464,7 +10464,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
1046410464
}
1046510465
}
1046610466
}
10467-
else if ((varTypeIsSIMD(tree) || varTypeIsIntegral(tree) || varTypeIsFloating(tree)) &&
10467+
else if (!tree->TypeIs(TYP_REF, TYP_BYREF, TYP_STRUCT) &&
1046810468
GetObjectHandleAndOffset(vnStore, tree->gtGetOp1(), &byteOffset, &obj))
1046910469
{
1047010470
// See if we can fold IND(ADD(FrozenObj, CNS)) to a constant
@@ -10754,12 +10754,18 @@ void Compiler::fgValueNumberTree(GenTree* tree)
1075410754

1075510755
if (!returnsTypeHandle)
1075610756
{
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()))
1076210760
{
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.
1076310769
assert(addrNvnp.BothEqual() && (addrXvnp == vnStore->VNPForEmptyExcSet()));
1076410770
ValueNum boxAddrVN = addrNvnp.GetLiberal();
1076510771
ValueNum fieldSeqVN = vnStore->VNForFieldSeq(nullptr);

0 commit comments

Comments
 (0)