Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove O1K_VALUE_NUMBER #101894

Merged
merged 1 commit into from
May 8, 2024
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
92 changes: 15 additions & 77 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,6 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse
printf("Const_Loop_Bnd_Un");
vnStore->vnDump(this, curAssertion->op1.vn);
}
else if (curAssertion->op1.kind == O1K_VALUE_NUMBER)
{
printf("Value_Number");
vnStore->vnDump(this, curAssertion->op1.vn);
}
else
{
printf("?op1.kind?");
Expand Down Expand Up @@ -897,18 +892,7 @@ void Compiler::optPrintAssertion(AssertionDsc* curAssertion, AssertionIndex asse
}
else
{
var_types op1Type;

if (curAssertion->op1.kind == O1K_VALUE_NUMBER)
{
op1Type = vnStore->TypeOfVN(curAssertion->op1.vn);
}
else
{
unsigned lclNum = curAssertion->op1.lcl.lclNum;
op1Type = lvaGetDesc(lclNum)->lvType;
}

var_types op1Type = lvaGetDesc(curAssertion->op1.lcl.lclNum)->lvType;
if (op1Type == TYP_REF)
{
if (curAssertion->op2.u1.iconVal == 0)
Expand Down Expand Up @@ -1175,64 +1159,23 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,

ValueNum vn;

//
// We only perform null-checks on GC refs
// so only make non-null assertions about GC refs or byrefs if we can't determine
// the corresponding ref.
//
if (lclVar->TypeGet() != TYP_REF)
// We only perform null-checks on byrefs and GC refs
if (!varTypeIsGC(lclVar->TypeGet()))
{
if (optLocalAssertionProp || (lclVar->TypeGet() != TYP_BYREF))
{
goto DONE_ASSERTION; // Don't make an assertion
}

vn = optConservativeNormalVN(op1);
VNFuncApp funcAttr;

// Try to get value number corresponding to the GC ref of the indirection
while (vnStore->GetVNFunc(vn, &funcAttr) && (funcAttr.m_func == (VNFunc)GT_ADD) &&
(vnStore->TypeOfVN(vn) == TYP_BYREF))
{
if (vnStore->IsVNConstant(funcAttr.m_args[1]) &&
varTypeIsIntegral(vnStore->TypeOfVN(funcAttr.m_args[1])))
{
offset += vnStore->CoercedConstantValue<ssize_t>(funcAttr.m_args[1]);
vn = funcAttr.m_args[0];
}
else if (vnStore->IsVNConstant(funcAttr.m_args[0]) &&
varTypeIsIntegral(vnStore->TypeOfVN(funcAttr.m_args[0])))
{
offset += vnStore->CoercedConstantValue<ssize_t>(funcAttr.m_args[0]);
vn = funcAttr.m_args[1];
}
else
{
break;
}
}

if (fgIsBigOffset(offset))
{
goto DONE_ASSERTION; // Don't make an assertion
}

assertion.op1.kind = O1K_VALUE_NUMBER;
goto DONE_ASSERTION; // Don't make an assertion
}
else
{
// If the local variable has its address exposed then bail
if (lclVar->IsAddressExposed())
{
goto DONE_ASSERTION; // Don't make an assertion
}

assertion.op1.kind = O1K_LCLVAR;
assertion.op1.lcl.lclNum = lclNum;
assertion.op1.lcl.ssaNum = op1->AsLclVarCommon()->GetSsaNum();
vn = optConservativeNormalVN(op1);
// If the local variable has its address exposed then bail
if (lclVar->IsAddressExposed())
{
goto DONE_ASSERTION; // Don't make an assertion
}

assertion.op1.kind = O1K_LCLVAR;
assertion.op1.lcl.lclNum = lclNum;
assertion.op1.lcl.ssaNum = op1->AsLclVarCommon()->GetSsaNum();
vn = optConservativeNormalVN(op1);

assertion.op1.vn = vn;
assertion.assertionKind = assertionKind;
assertion.op2.kind = O2K_CONST_INT;
Expand Down Expand Up @@ -1597,7 +1540,7 @@ AssertionIndex Compiler::optFinalizeCreatingAssertion(AssertionDsc* assertion)
}

// TODO: only copy assertions rely on valid SSA number so we could generate more assertions here
if ((assertion->op1.kind != O1K_VALUE_NUMBER) && (assertion->op1.lcl.ssaNum == SsaConfig::RESERVED_SSA_NUM))
if (assertion->op1.lcl.ssaNum == SsaConfig::RESERVED_SSA_NUM)
{
return NO_ASSERTION_INDEX;
}
Expand Down Expand Up @@ -1866,7 +1809,6 @@ void Compiler::optDebugCheckAssertion(AssertionDsc* assertion)
case O1K_BOUND_LOOP_BND:
case O1K_CONSTANT_LOOP_BND:
case O1K_CONSTANT_LOOP_BND_UN:
case O1K_VALUE_NUMBER:
assert(!optLocalAssertionProp);
break;
default:
Expand All @@ -1887,9 +1829,6 @@ void Compiler::optDebugCheckAssertion(AssertionDsc* assertion)
assert((lvaGetDesc(assertion->op1.lcl.lclNum)->lvType != TYP_REF) ||
(assertion->op2.u1.iconVal == 0) || doesMethodHaveFrozenObjects());
break;
case O1K_VALUE_NUMBER:
assert((vnStore->TypeOfVN(assertion->op1.vn) != TYP_REF) || (assertion->op2.u1.iconVal == 0));
break;
default:
break;
}
Expand Down Expand Up @@ -5680,8 +5619,7 @@ void Compiler::optImpliedByTypeOfAssertions(ASSERT_TP& activeAssertions)
}

// impAssertion must be a Non Null assertion on lclNum
if ((impAssertion->assertionKind != OAK_NOT_EQUAL) ||
((impAssertion->op1.kind != O1K_LCLVAR) && (impAssertion->op1.kind != O1K_VALUE_NUMBER)) ||
if ((impAssertion->assertionKind != OAK_NOT_EQUAL) || (impAssertion->op1.kind != O1K_LCLVAR) ||
(impAssertion->op2.kind != O2K_CONST_INT) || (impAssertion->op1.vn != chkAssertion->op1.vn))
{
continue;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7536,7 +7536,6 @@ class Compiler
O1K_CONSTANT_LOOP_BND_UN,
O1K_EXACT_TYPE,
O1K_SUBTYPE,
O1K_VALUE_NUMBER,
O1K_COUNT
};

Expand Down
Loading