From 3fce4e73b802c07708a115ce47583bd296a26230 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Wed, 8 May 2024 13:30:29 +0200 Subject: [PATCH] Remove O1K_VALUE_NUMBER (#101894) --- src/coreclr/jit/assertionprop.cpp | 92 +++++-------------------------- src/coreclr/jit/compiler.h | 1 - 2 files changed, 15 insertions(+), 78 deletions(-) diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index b3d52ce9773e4..6e30d4874e447 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -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?"); @@ -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) @@ -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(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(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; @@ -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; } @@ -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: @@ -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; } @@ -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; diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 15b9d847aad39..c40d7655f5f32 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -7533,7 +7533,6 @@ class Compiler O1K_CONSTANT_LOOP_BND_UN, O1K_EXACT_TYPE, O1K_SUBTYPE, - O1K_VALUE_NUMBER, O1K_COUNT };