diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 796043ac61dab8..3053b8427f5c61 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -366,7 +366,7 @@ void Compiler::impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsu // needs to be spilled to preserve correct ordering. // GenTree* expr = stmt->GetRootNode(); - GenTreeFlags flags = expr->gtFlags & GTF_GLOB_EFFECT; + GenTreeFlags flags = expr->gtFlags & GTF_ALL_EFFECT; // Stores to unaliased locals require special handling. Here, we look for trees that // can modify them and spill the references. In doing so, we make two assumptions: @@ -416,7 +416,7 @@ void Compiler::impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsu { // For stores, limit the checking to what the value could modify/interfere with. GenTree* value = expr->AsLclVarCommon()->Data(); - flags = value->gtFlags & GTF_GLOB_EFFECT; + flags = value->gtFlags & GTF_ALL_EFFECT; // We don't mark indirections off of "aliased" locals with GLOB_REF, but they must still be // considered as such in the interference checking. @@ -429,7 +429,9 @@ void Compiler::impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsu if (flags != 0) { - impSpillSideEffects((flags & (GTF_ASG | GTF_CALL)) != 0, chkLevel DEBUGARG("impAppendStmt")); + // Ordering side effects must not move ahead of global reads. + impSpillSideEffects((flags & (GTF_ASG | GTF_CALL | GTF_ORDER_SIDEEFF)) != 0, + chkLevel DEBUGARG("impAppendStmt")); } else { @@ -1839,7 +1841,7 @@ void Compiler::impSpillSideEffect(bool spillGlobEffects, unsigned i DEBUGARG(con { assert(i <= stackState.esStackDepth); - GenTreeFlags spillFlags = spillGlobEffects ? GTF_GLOB_EFFECT : GTF_SIDE_EFFECT; + GenTreeFlags spillFlags = spillGlobEffects ? GTF_ALL_EFFECT : (GTF_SIDE_EFFECT | GTF_ORDER_SIDEEFF); GenTree* tree = stackState.esStack[i].val; if ((tree->gtFlags & spillFlags) != 0 || diff --git a/src/coreclr/jit/importervectorization.cpp b/src/coreclr/jit/importervectorization.cpp index 8dfdd8b30d9061..d59185514af5ae 100644 --- a/src/coreclr/jit/importervectorization.cpp +++ b/src/coreclr/jit/importervectorization.cpp @@ -519,15 +519,12 @@ GenTree* Compiler::impUtf16StringComparison(StringComparisonKind kind, CORINFO_S impPopStack(argsCount); - // Include global reads so nonfaulting volatile loads stay ahead of the comparison. - impSpillSideEffects(true, CHECK_SPILL_ALL DEBUGARG("unrolled UTF16 string comparison")); - - impStoreToTemp(varStrTmp, varStr, CHECK_SPILL_NONE); + impStoreToTemp(varStrTmp, varStr, CHECK_SPILL_ALL); if (unrolled->OperIs(GT_QMARK)) { // QMARK nodes cannot reside on the evaluation stack unsigned rootTmp = lvaGrabTemp(true DEBUGARG("spilling unroll qmark")); - impStoreToTemp(rootTmp, unrolled, CHECK_SPILL_NONE); + impStoreToTemp(rootTmp, unrolled, CHECK_SPILL_ALL); unrolled = gtNewLclvNode(rootTmp, TYP_INT); } @@ -691,19 +688,16 @@ GenTree* Compiler::impUtf16SpanComparison(StringComparisonKind kind, CORINFO_SIG { impPopStack(argsCount); - // Include global reads so nonfaulting volatile loads stay ahead of the comparison. - impSpillSideEffects(true, CHECK_SPILL_ALL DEBUGARG("unrolled UTF16 span comparison")); - if (!spanObj->OperIs(GT_LCL_VAR)) { - impStoreToTemp(spanLclNum, spanObj, CHECK_SPILL_NONE); + impStoreToTemp(spanLclNum, spanObj, CHECK_SPILL_ALL); } if (unrolled->OperIs(GT_QMARK)) { // QMARK can't be a root node, spill it to a temp unsigned rootTmp = lvaGrabTemp(true DEBUGARG("spilling unroll qmark")); - impStoreToTemp(rootTmp, unrolled, CHECK_SPILL_NONE); + impStoreToTemp(rootTmp, unrolled, CHECK_SPILL_ALL); unrolled = gtNewLclvNode(rootTmp, TYP_INT); }