JIT: detect address of field as an invariant inlining arg (#845)
authorAndy Ayers <andya@microsoft.com>
Mon, 16 Dec 2019 20:03:15 +0000 (12:03 -0800)
committerGitHub <noreply@github.com>
Mon, 16 Dec 2019 20:03:15 +0000 (12:03 -0800)
Update the check for arg invariance to include addresses of fields in local
structs. This allows the inliner to directly substitute more arguments into
the body of the inlinee.

Resolves dotnet/coreclr#27630.

src/coreclr/src/jit/importer.cpp

index 9bab752..a409192 100644 (file)
@@ -18582,7 +18582,9 @@ void Compiler::impInlineRecordArgInfo(InlineInfo*   pInlineInfo,
     inlCurArgInfo->argNode = curArgVal;
 
     GenTree* lclVarTree;
-    if (impIsAddressInLocal(curArgVal, &lclVarTree) && varTypeIsStruct(lclVarTree))
+
+    const bool isAddressInLocal = impIsAddressInLocal(curArgVal, &lclVarTree);
+    if (isAddressInLocal && varTypeIsStruct(lclVarTree))
     {
         inlCurArgInfo->argIsByRefToStructLocal = true;
 #ifdef FEATURE_SIMD
@@ -18607,8 +18609,7 @@ void Compiler::impInlineRecordArgInfo(InlineInfo*   pInlineInfo,
         INDEBUG(curArgVal->AsLclVar()->gtLclILoffs = argNum;)
     }
 
-    if ((curArgVal->OperKind() & GTK_CONST) ||
-        ((curArgVal->gtOper == GT_ADDR) && (curArgVal->AsOp()->gtOp1->gtOper == GT_LCL_VAR)))
+    if ((curArgVal->OperKind() & GTK_CONST) || isAddressInLocal)
     {
         inlCurArgInfo->argIsInvariant = true;
         if (inlCurArgInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->AsIntCon()->gtIconVal == 0))