Correctly pass 12-byte GT_SIMD nodes on x86.
authorPat Gavlin <pagavlin@microsoft.com>
Tue, 21 Feb 2017 21:29:34 +0000 (13:29 -0800)
committerPat Gavlin <pagavlin@microsoft.com>
Tue, 21 Feb 2017 21:33:33 +0000 (13:33 -0800)
During lowering, all TYP_SIMD12 GT_SIMD nodes are retyped to TYP_SIMD16.
This is correct except in the case that the GT_SIMD node is going to be
passed by-value on x86, in which case this retyping causes us to push 16
bytes rather than 12. This change recognizes a GT_SIMD node that has
been retyped by checking the value of gtSIMDSize during LowerArg and
uses TYP_SIMD12 for the putarg instead of TYP_SIMD16 (aside from
differences in detecting retyped nodes, this is the same transformation
we already do when passing TYP_SIMD12 lclVars that are being used as
TYP_SIMD16 on x86).

Fixes https://github.com/dotnet/corefx/issues/15913.

Commit migrated from https://github.com/dotnet/coreclr/commit/57c83fb63d8d8f442f9c7d0c93cb4f722eead545

src/coreclr/src/jit/lower.cpp

index b3a674e..efa1be4 100644 (file)
@@ -1062,6 +1062,15 @@ void Lowering::LowerArg(GenTreeCall* call, GenTreePtr* ppArg)
             LclVarDsc* varDsc = &comp->lvaTable[varNum];
             type              = varDsc->lvType;
         }
+        else if (arg->OperGet() == GT_SIMD)
+        {
+            assert((arg->AsSIMD()->gtSIMDSize == 16) || (arg->AsSIMD()->gtSIMDSize == 12));
+
+            if (arg->AsSIMD()->gtSIMDSize == 12)
+            {
+                type = TYP_SIMD12;
+            }
+        }
     }
 #endif // defined(FEATURE_SIMD) && defined(_TARGET_X86_)