Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improve TP
  • Loading branch information
EgorBo committed Nov 29, 2022
commit 62befef3f62a3652f5335274defabbe38072af75
63 changes: 63 additions & 0 deletions 0001-Improve-GetStaticFieldSeqAndAddress.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 68137c0aa93b554815760219db2110a70a31ecf9 Mon Sep 17 00:00:00 2001
From: EgorBo <[email protected]>
Date: Tue, 29 Nov 2022 12:48:46 +0100
Subject: [PATCH] Improve GetStaticFieldSeqAndAddress

---
src/coreclr/jit/valuenum.cpp | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp
index ce724c0dc04..a3fbb45310b 100644
--- a/src/coreclr/jit/valuenum.cpp
+++ b/src/coreclr/jit/valuenum.cpp
@@ -8578,6 +8578,7 @@ void Compiler::fgValueNumberSsaVarDef(GenTreeLclVarCommon* lcl)
// tree where only one of the constants is expected to have a field sequence.
//
// Arguments:
+// vnStore - ValueNumStore object
// tree - tree node to inspect
// pAddress - [Out] resulting address with all offsets combined
// pFseq - [Out] field sequence
@@ -8585,7 +8586,7 @@ void Compiler::fgValueNumberSsaVarDef(GenTreeLclVarCommon* lcl)
// Return Value:
// true if the given tree is a static field address
//
-static bool fgGetStaticFieldSeqAndAddress(GenTree* tree, ssize_t* pAddress, FieldSeq** pFseq)
+static bool GetStaticFieldSeqAndAddress(ValueNumStore* vnStore, GenTree* tree, ssize_t* pAddress, FieldSeq** pFseq)
{
ssize_t val = 0;
// Accumulate final offset
@@ -8593,14 +8594,16 @@ static bool fgGetStaticFieldSeqAndAddress(GenTree* tree, ssize_t* pAddress, Fiel
{
GenTree* op1 = tree->gtGetOp1();
GenTree* op2 = tree->gtGetOp2();
- if (op1->IsCnsIntOrI() && (op1->AsIntCon()->gtFieldSeq == nullptr))
+ if (!op1->IsIconHandle(GTF_ICON_STATIC_HDL) && op1->gtVNPair.BothEqual() &&
+ vnStore->IsVNConstant(op1->gtVNPair.GetLiberal()))
{
- val += op1->AsIntCon()->IconValue();
+ val += vnStore->CoercedConstantValue<size_t>(op1->gtVNPair.GetLiberal());
tree = op2;
}
- else if (op2->IsCnsIntOrI() && (op2->AsIntCon()->gtFieldSeq == nullptr))
+ else if (!op2->IsIconHandle(GTF_ICON_STATIC_HDL) && op2->gtVNPair.BothEqual() &&
+ vnStore->IsVNConstant(op2->gtVNPair.GetLiberal()))
{
- val += op2->AsIntCon()->IconValue();
+ val += vnStore->CoercedConstantValue<size_t>(op2->gtVNPair.GetLiberal());
tree = op1;
}
else
@@ -8646,7 +8649,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
//
ssize_t address = 0;
FieldSeq* fieldSeq = nullptr;
- if (fgGetStaticFieldSeqAndAddress(tree->gtGetOp1(), &address, &fieldSeq))
+ if (GetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &address, &fieldSeq))
{
assert(fieldSeq->GetKind() == FieldSeq::FieldKind::SimpleStaticKnownAddress);
CORINFO_FIELD_HANDLE fieldHandle = fieldSeq->GetFieldHandle();
--
2.29.2.windows.2

2 changes: 1 addition & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8574,7 +8574,7 @@ bool Compiler::fgValueNumberConstLoad(GenTreeIndir* tree)
//
ssize_t address = 0;
FieldSeq* fieldSeq = nullptr;
if (GetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &address, &fieldSeq))
if (varTypeIsIntegral(tree) && GetStaticFieldSeqAndAddress(vnStore, tree->gtGetOp1(), &address, &fieldSeq))
{
assert(fieldSeq->GetKind() == FieldSeq::FieldKind::SimpleStaticKnownAddress);
CORINFO_FIELD_HANDLE fieldHandle = fieldSeq->GetFieldHandle();
Expand Down