Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 12 additions & 1 deletion src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,18 @@ struct GenTree

bool IsNotGcDef() const
{
return IsIntegralConst(0) || OperIs(GT_LCL_ADDR);
if (IsIntegralConst(0) || OperIs(GT_LCL_ADDR))
{
return true;
}

// Any NonGC object or NonGC object + any offset.
if (IsIconHandle(GTF_ICON_OBJ_HDL) || (OperIs(GT_ADD) && gtGetOp1()->IsIconHandle(GTF_ICON_OBJ_HDL)))
{
return true;
}

return false;
}

// LIR flags
Expand Down
19 changes: 18 additions & 1 deletion src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15215,8 +15215,25 @@ void ValueNumStore::PeelOffsets(ValueNum* vn, target_ssize_t* offset)

*offset = 0;
VNFuncApp app;
while (GetVNFunc(*vn, &app) && (app.m_func == VNF_ADD))
while (GetVNFunc(*vn, &app) && ((app.m_func == VNF_ADD) || (app.m_func == VNF_Cast)))
{
if (app.m_func == VNF_Cast)
{
// Ignore GC -> I_IMPL casts during peeling
if (TypeOfVN(*vn) == TYP_I_IMPL)
{
var_types castToType;
bool srcIsUnsigned;
GetCastOperFromVN(app.m_args[1], &castToType, &srcIsUnsigned);
if (varTypeIsI(castToType) && varTypeIsI(TypeOfVN(app.m_args[0])))
{
*vn = app.m_args[0];
continue;
}
}
break;
}

// We don't treat handles and null as constant offset.

if (IsVNConstantNonHandle(app.m_args[0]) && (app.m_args[0] != VNForNull()))
Expand Down
Loading