@@ -4250,68 +4250,6 @@ GenTree* Compiler::optAssertionProp_RelOp(ASSERT_VALARG_TP assertions,
42504250 return optAssertionPropLocal_RelOp (assertions, tree, stmt);
42514251}
42524252
4253- // --------------------------------------------------------------------------------
4254- // optVisitReachingAssertions: given a vn, call the specified callback function on all
4255- // the assertions that reach it via PHI definitions if any.
4256- //
4257- // Arguments:
4258- // vn - The vn to visit all the reaching assertions for
4259- // argVisitor - The callback function to call on the vn and its reaching assertions
4260- //
4261- // Return Value:
4262- // AssertVisit::Aborted - an argVisitor returned AssertVisit::Abort, we stop the walk and return
4263- // AssertVisit::Continue - all argVisitor returned AssertVisit::Continue
4264- //
4265- template <typename TAssertVisitor>
4266- Compiler::AssertVisit Compiler::optVisitReachingAssertions (ValueNum vn, TAssertVisitor argVisitor)
4267- {
4268- VNPhiDef phiDef;
4269- if (!vnStore->GetPhiDef (vn, &phiDef))
4270- {
4271- // We assume that the caller already checked assertions for the current block, so we're
4272- // interested only in assertions for PHI definitions.
4273- return AssertVisit::Abort;
4274- }
4275-
4276- LclSsaVarDsc* ssaDef = lvaGetDesc (phiDef.LclNum )->GetPerSsaData (phiDef.SsaDef );
4277- GenTreeLclVarCommon* node = ssaDef->GetDefNode ();
4278- assert (node->IsPhiDefn ());
4279-
4280- // Keep track of the set of phi-preds
4281- //
4282- BitVecTraits traits (fgBBNumMax + 1 , this );
4283- BitVec visitedBlocks = BitVecOps::MakeEmpty (&traits);
4284-
4285- for (GenTreePhi::Use& use : node->Data ()->AsPhi ()->Uses ())
4286- {
4287- GenTreePhiArg* phiArg = use.GetNode ()->AsPhiArg ();
4288- const ValueNum phiArgVN = vnStore->VNConservativeNormalValue (phiArg->gtVNPair );
4289- ASSERT_TP assertions = optGetEdgeAssertions (ssaDef->GetBlock (), phiArg->gtPredBB );
4290- if (argVisitor (phiArgVN, assertions) == AssertVisit::Abort)
4291- {
4292- // The visitor wants to abort the walk.
4293- return AssertVisit::Abort;
4294- }
4295- BitVecOps::AddElemD (&traits, visitedBlocks, phiArg->gtPredBB ->bbNum );
4296- }
4297-
4298- // Verify the set of phi-preds covers the set of block preds
4299- //
4300- for (BasicBlock* const pred : ssaDef->GetBlock ()->PredBlocks ())
4301- {
4302- if (!BitVecOps::IsMember (&traits, visitedBlocks, pred->bbNum ))
4303- {
4304- JITDUMP (" ... optVisitReachingAssertions in " FMT_BB " : pred " FMT_BB " not a phi-pred\n " ,
4305- ssaDef->GetBlock ()->bbNum , pred->bbNum );
4306-
4307- // We missed examining a block pred. Fail the phi inference.
4308- //
4309- return AssertVisit::Abort;
4310- }
4311- }
4312- return AssertVisit::Continue;
4313- }
4314-
43154253// ------------------------------------------------------------------------
43164254// optAssertionProp: try and optimize a relop via assertion propagation
43174255//
@@ -4400,7 +4338,7 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions,
44004338 ValueNum op1VN = vnStore->VNConservativeNormalValue (op1->gtVNPair );
44014339 ValueNum op2VN = vnStore->VNConservativeNormalValue (op2->gtVNPair );
44024340
4403- // See if we can fold "X relop CNS" using TryGetRangeFromAssertions .
4341+ // IsVNIntegralConstant for op2VN is for reducing the TP regression, can be removed .
44044342 int op2cns;
44054343 if (op1->TypeIs (TYP_INT) && op2->TypeIs (TYP_INT) && vnStore->IsVNIntegralConstant (op2VN, &op2cns))
44064344 {
@@ -4439,11 +4377,12 @@ GenTree* Compiler::optAssertionPropGlobal_RelOp(ASSERT_VALARG_TP assertions,
44394377 {
44404378 JITDUMP (" Checking PHI [%06u] arguments for non-nullness\n " , dspTreeID (op1))
44414379 auto visitor = [this ](ValueNum reachingVN, ASSERT_TP reachingAssertions) {
4442- return optAssertionVNIsNonNull (reachingVN, reachingAssertions) ? AssertVisit::Continue : AssertVisit::Abort;
4380+ return optAssertionVNIsNonNull (reachingVN, reachingAssertions) ? RangeCheck::AssertVisit::Continue
4381+ : RangeCheck::AssertVisit::Abort;
44434382 };
44444383
44454384 ValueNum op1vn = vnStore->VNConservativeNormalValue (op1->gtVNPair );
4446- if (optVisitReachingAssertions (op1vn, visitor) == AssertVisit::Continue)
4385+ if (RangeCheck:: optVisitReachingAssertions (this , op1vn, visitor) == RangeCheck:: AssertVisit::Continue)
44474386 {
44484387 JITDUMP (" ... all of PHI's arguments are never null!\n " );
44494388 assert (newTree->OperIs (GT_EQ, GT_NE));
0 commit comments