Skip to content

Commit

Permalink
Remove O1K_VALUE_NUMBER
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed May 6, 2024
1 parent 358b0a4 commit 1ea7413
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 82 deletions.
92 changes: 11 additions & 81 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,17 +892,8 @@ 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;
}
unsigned lclNum = curAssertion->op1.lcl.lclNum;
var_types op1Type = lvaGetDesc(lclNum)->lvType;

if (op1Type == TYP_REF)
{
Expand Down Expand Up @@ -1173,67 +1159,16 @@ AssertionIndex Compiler::optCreateAssertion(GenTree* op1,
unsigned lclNum = op1->AsLclVarCommon()->GetLclNum();
LclVarDsc* lclVar = lvaGetDesc(lclNum);

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)
{
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;
}
else
// If the local variable has its address exposed then bail
if (lclVar->IsAddressExposed())
{
// 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);
goto DONE_ASSERTION; // Don't make an assertion
}

assertion.op1.vn = vn;
assertion.op1.kind = O1K_LCLVAR;
assertion.op1.lcl.lclNum = lclNum;
assertion.op1.lcl.ssaNum = op1->AsLclVarCommon()->GetSsaNum();
assertion.op1.vn = optConservativeNormalVN(op1);
assertion.assertionKind = assertionKind;
assertion.op2.kind = O2K_CONST_INT;
assertion.op2.vn = ValueNumStore::VNForNull();
Expand Down Expand Up @@ -1597,7 +1532,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 +1801,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 +1821,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 +5611,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

0 comments on commit 1ea7413

Please sign in to comment.