From: Tanner Gooding Date: Tue, 31 Jan 2023 02:55:45 +0000 (-0800) Subject: Update fgGetTopLevelQmark to handle GT_LCL_FLD (#81375) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4329 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fb2df0dbd1c39ebcadee1f90bcafdf38358fb80;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Update fgGetTopLevelQmark to handle GT_LCL_FLD (#81375) --- diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 82cfb35..4d01281 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -13990,10 +13990,10 @@ void Compiler::fgPreExpandQmarkChecks(GenTree* expr) { // We could probably expand the cond node also, but don't think the extra effort is necessary, // so let's just assert the cond node of a top level qmark doesn't have further top level qmarks. - assert(!gtTreeContainsOper(topQmark->AsOp()->gtOp1, GT_QMARK) && "Illegal QMARK"); + assert(!gtTreeContainsOper(topQmark->gtGetOp1(), GT_QMARK) && "Illegal QMARK"); - fgPreExpandQmarkChecks(topQmark->AsOp()->gtOp2->AsOp()->gtOp1); - fgPreExpandQmarkChecks(topQmark->AsOp()->gtOp2->AsOp()->gtOp2); + fgPreExpandQmarkChecks(topQmark->gtGetOp2()->gtGetOp1()); + fgPreExpandQmarkChecks(topQmark->gtGetOp2()->gtGetOp2()); } } @@ -14034,19 +14034,22 @@ GenTree* Compiler::fgGetTopLevelQmark(GenTree* expr, GenTree** ppDst /* = NULL * } GenTree* topQmark = nullptr; + if (expr->gtOper == GT_QMARK) { topQmark = expr; } - else if (expr->gtOper == GT_ASG && expr->AsOp()->gtOp2->gtOper == GT_QMARK && - expr->AsOp()->gtOp1->gtOper == GT_LCL_VAR) + else if (expr->OperIs(GT_ASG) && expr->gtGetOp2()->OperIs(GT_QMARK) && + expr->gtGetOp1()->OperIs(GT_LCL_VAR, GT_LCL_FLD)) { - topQmark = expr->AsOp()->gtOp2; + topQmark = expr->gtGetOp2(); + if (ppDst != nullptr) { - *ppDst = expr->AsOp()->gtOp1; + *ppDst = expr->gtGetOp1(); } } + return topQmark; } @@ -14094,7 +14097,9 @@ void Compiler::fgExpandQmarkForCastInstOf(BasicBlock* block, Statement* stmt) GenTree* dst = nullptr; GenTree* qmark = fgGetTopLevelQmark(expr, &dst); + noway_assert(dst != nullptr); + assert(dst->OperIs(GT_LCL_VAR, GT_LCL_FLD)); assert(qmark->gtFlags & GTF_QMARK_CAST_INSTOF); @@ -14193,13 +14198,13 @@ void Compiler::fgExpandQmarkForCastInstOf(BasicBlock* block, Statement* stmt) fgInsertStmtAtEnd(cond2Block, jmpStmt); // AsgBlock should get tmp = op1 assignment. - trueExpr = gtNewTempAssign(dst->AsLclVarCommon()->GetLclNum(), trueExpr); + trueExpr = gtNewAssignNode(gtClone(dst), trueExpr); Statement* trueStmt = fgNewStmtFromTree(trueExpr, stmt->GetDebugInfo()); fgInsertStmtAtEnd(asgBlock, trueStmt); // Since we are adding helper in the JTRUE false path, reverse the cond2 and add the helper. gtReverseCond(cond2Expr); - GenTree* helperExpr = gtNewTempAssign(dst->AsLclVarCommon()->GetLclNum(), true2Expr); + GenTree* helperExpr = gtNewAssignNode(gtClone(dst), true2Expr); Statement* helperStmt = fgNewStmtFromTree(helperExpr, stmt->GetDebugInfo()); fgInsertStmtAtEnd(helperBlock, helperStmt); @@ -14408,11 +14413,9 @@ void Compiler::fgExpandQmarkStmt(BasicBlock* block, Statement* stmt) // Since we have top level qmarks, we either have a dst for it in which case // we need to create tmps for true and falseExprs, else just don't bother // assigning. - unsigned lclNum = BAD_VAR_NUM; if (dst != nullptr) { - assert(dst->gtOper == GT_LCL_VAR); - lclNum = dst->AsLclVar()->GetLclNum(); + assert(dst->OperIs(GT_LCL_VAR, GT_LCL_FLD)); } else { @@ -14423,7 +14426,7 @@ void Compiler::fgExpandQmarkStmt(BasicBlock* block, Statement* stmt) { if (dst != nullptr) { - trueExpr = gtNewTempAssign(lclNum, trueExpr); + trueExpr = gtNewAssignNode(gtClone(dst), trueExpr); } Statement* trueStmt = fgNewStmtFromTree(trueExpr, stmt->GetDebugInfo()); fgInsertStmtAtEnd(thenBlock, trueStmt); @@ -14434,7 +14437,7 @@ void Compiler::fgExpandQmarkStmt(BasicBlock* block, Statement* stmt) { if (dst != nullptr) { - falseExpr = gtNewTempAssign(lclNum, falseExpr); + falseExpr = gtNewAssignNode(gtClone(dst), falseExpr); } Statement* falseStmt = fgNewStmtFromTree(falseExpr, stmt->GetDebugInfo()); fgInsertStmtAtEnd(elseBlock, falseStmt);