summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarol Eidt <carol.eidt@microsoft.com>2019-01-08 17:46:17 -0800
committerGitHub <noreply@github.com>2019-01-08 17:46:17 -0800
commit687ba57ae4e3df6aaa539898dea99ac2d918554a (patch)
tree986be4b71cdc3ed2c5c0d9d485b0d32cfec920df
parentd31cd214adbb14724a829f577b6861ed2239a03b (diff)
downloadcoreclr-687ba57ae4e3df6aaa539898dea99ac2d918554a.tar.gz
coreclr-687ba57ae4e3df6aaa539898dea99ac2d918554a.tar.bz2
coreclr-687ba57ae4e3df6aaa539898dea99ac2d918554a.zip
Copy address-taken SIMD intrinsic (#21884)
* Copy address-taken SIMD intrinsic This occurs, for example, when boxing the result of a SIMD intrinsic. This was being handled for the HW intrinsic case, but not the SIMD Vector intrinsics. Also, eliminate `OperIsSimdHWIntrisic` since it redundantly checks for the case of a SIMD result, even though it was always called in a context where the result is known to be a struct type. Fix #21854
-rw-r--r--src/jit/gentree.h22
-rw-r--r--src/jit/importer.cpp11
-rw-r--r--src/jit/lowerarmarch.cpp2
-rw-r--r--src/jit/lowerxarch.cpp2
-rw-r--r--src/jit/morph.cpp12
-rw-r--r--src/jit/rationalize.cpp2
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.cs27
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.csproj33
8 files changed, 75 insertions, 36 deletions
diff --git a/src/jit/gentree.h b/src/jit/gentree.h
index 9846ceab09..39c9e678bd 100644
--- a/src/jit/gentree.h
+++ b/src/jit/gentree.h
@@ -1518,18 +1518,9 @@ public:
return OperIsHWIntrinsic(gtOper);
}
-#ifdef FEATURE_HW_INTRINSICS
- inline bool OperIsSimdHWIntrinsic() const;
-#else
- inline bool OperIsSimdHWIntrinsic() const
- {
- return false;
- }
-#endif
-
- bool OperIsSIMDorSimdHWintrinsic() const
+ bool OperIsSimdOrHWintrinsic() const
{
- return OperIsSIMD() || OperIsSimdHWIntrinsic();
+ return OperIsSIMD() || OperIsHWIntrinsic();
}
// This is here for cleaner GT_LONG #ifdefs.
@@ -4135,15 +4126,6 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic
}
#endif
};
-
-inline bool GenTree::OperIsSimdHWIntrinsic() const
-{
- if (gtOper == GT_HWIntrinsic)
- {
- return this->AsHWIntrinsic()->isSIMD();
- }
- return false;
-}
#endif // FEATURE_HW_INTRINSICS
/* gtIndex -- array access */
diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp
index 30812737ad..76844307f7 100644
--- a/src/jit/importer.cpp
+++ b/src/jit/importer.cpp
@@ -1143,11 +1143,8 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr,
ilOffset = impCurStmtOffs;
}
- assert(src->gtOper == GT_LCL_VAR || src->gtOper == GT_FIELD || src->gtOper == GT_IND || src->gtOper == GT_OBJ ||
- src->gtOper == GT_CALL || src->gtOper == GT_MKREFANY || src->gtOper == GT_RET_EXPR ||
- src->gtOper == GT_COMMA ||
- (src->TypeGet() != TYP_STRUCT &&
- (GenTree::OperIsSIMD(src->gtOper) || src->OperIsSimdHWIntrinsic() || src->gtOper == GT_LCL_FLD)));
+ assert(src->OperIs(GT_LCL_VAR, GT_FIELD, GT_IND, GT_OBJ, GT_CALL, GT_MKREFANY, GT_RET_EXPR, GT_COMMA) ||
+ (src->TypeGet() != TYP_STRUCT && (src->OperIsSimdOrHWintrinsic() || src->OperIs(GT_LCL_FLD))));
if (destAddr->OperGet() == GT_ADDR)
{
@@ -1426,7 +1423,7 @@ GenTree* Compiler::impGetStructAddr(GenTree* structVal,
return (structVal->gtObj.Addr());
}
else if (oper == GT_CALL || oper == GT_RET_EXPR || oper == GT_OBJ || oper == GT_MKREFANY ||
- structVal->OperIsSimdHWIntrinsic())
+ structVal->OperIsSimdOrHWintrinsic())
{
unsigned tmpNum = lvaGrabTemp(true DEBUGARG("struct address for call/obj"));
@@ -1689,7 +1686,7 @@ GenTree* Compiler::impNormStructVal(GenTree* structVal,
}
#ifdef FEATURE_SIMD
- if (blockNode->OperIsSIMDorSimdHWintrinsic())
+ if (blockNode->OperIsSimdOrHWintrinsic())
{
parent->gtOp.gtOp2 = impNormStructVal(blockNode, structHnd, curLevel, forceNormalization);
alreadyNormalized = true;
diff --git a/src/jit/lowerarmarch.cpp b/src/jit/lowerarmarch.cpp
index d8d23eb0c2..4b28ce260a 100644
--- a/src/jit/lowerarmarch.cpp
+++ b/src/jit/lowerarmarch.cpp
@@ -357,7 +357,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
addr->ClearContained();
}
}
- else if (!source->IsMultiRegCall() && !source->OperIsSIMDorSimdHWintrinsic())
+ else if (!source->IsMultiRegCall() && !source->OperIsSimdOrHWintrinsic())
{
assert(source->IsLocal());
MakeSrcContained(blkNode, source);
diff --git a/src/jit/lowerxarch.cpp b/src/jit/lowerxarch.cpp
index 7eb7edf899..124185dd1f 100644
--- a/src/jit/lowerxarch.cpp
+++ b/src/jit/lowerxarch.cpp
@@ -391,7 +391,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
addr->ClearContained();
}
}
- else if (!source->IsMultiRegCall() && !source->OperIsSIMD() && !source->OperIsSimdHWIntrinsic())
+ else if (!source->IsMultiRegCall() && !source->OperIsSimdOrHWintrinsic())
{
assert(source->IsLocal());
MakeSrcContained(blkNode, source);
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index b2cb5859cb..ee31beb698 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -1594,9 +1594,9 @@ void fgArgInfo::ArgsComplete()
else if (isMultiRegArg && varTypeIsSIMD(argx->TypeGet()))
{
// SIMD types do not need the optimization below due to their sizes
- if (argx->OperIsSIMDorSimdHWintrinsic() ||
+ if (argx->OperIsSimdOrHWintrinsic() ||
(argx->OperIs(GT_OBJ) && argx->AsObj()->gtOp1->OperIs(GT_ADDR) &&
- argx->AsObj()->gtOp1->gtOp.gtOp1->OperIsSIMDorSimdHWintrinsic()))
+ argx->AsObj()->gtOp1->gtOp.gtOp1->OperIsSimdOrHWintrinsic()))
{
curArgTabEntry->needTmp = true;
}
@@ -8936,7 +8936,7 @@ GenTree* Compiler::fgMorphOneAsgBlockOp(GenTree* tree)
// in codegen.
// TODO-1stClassStructs: This is here to preserve old behavior.
// It should be eliminated.
- if (src->OperIsSIMDorSimdHWintrinsic())
+ if (src->OperIsSimdOrHWintrinsic())
{
return nullptr;
}
@@ -9856,13 +9856,13 @@ GenTree* Compiler::fgMorphBlockOperand(GenTree* tree, var_types asgType, unsigne
if (varTypeIsSIMD(asgType))
{
if ((indirTree != nullptr) && (lclNode == nullptr) && (indirTree->Addr()->OperGet() == GT_ADDR) &&
- (indirTree->Addr()->gtGetOp1()->OperIsSIMDorSimdHWintrinsic()))
+ (indirTree->Addr()->gtGetOp1()->OperIsSimdOrHWintrinsic()))
{
assert(!isDest);
needsIndirection = false;
effectiveVal = indirTree->Addr()->gtGetOp1();
}
- if (effectiveVal->OperIsSIMDorSimdHWintrinsic())
+ if (effectiveVal->OperIsSimdOrHWintrinsic())
{
needsIndirection = false;
}
@@ -11032,7 +11032,7 @@ GenTree* Compiler::getSIMDStructFromField(GenTree* tree,
*pBaseTypeOut = simdNode->gtSIMDBaseType;
}
#ifdef FEATURE_HW_INTRINSICS
- else if (obj->OperIsSimdHWIntrinsic())
+ else if (obj->OperIsHWIntrinsic())
{
ret = obj;
GenTreeHWIntrinsic* simdNode = obj->AsHWIntrinsic();
diff --git a/src/jit/rationalize.cpp b/src/jit/rationalize.cpp
index 407c9f832e..1cdb54f214 100644
--- a/src/jit/rationalize.cpp
+++ b/src/jit/rationalize.cpp
@@ -104,7 +104,7 @@ void Rationalizer::RewriteSIMDOperand(LIR::Use& use, bool keepBlk)
addr->gtType = simdType;
use.ReplaceWith(comp, addr);
}
- else if ((addr->OperGet() == GT_ADDR) && (addr->gtGetOp1()->OperIsSIMDorSimdHWintrinsic()))
+ else if ((addr->OperGet() == GT_ADDR) && (addr->gtGetOp1()->OperIsSimdOrHWintrinsic()))
{
// if we have GT_IND(GT_ADDR(GT_SIMD)), remove the GT_IND(GT_ADDR()), leaving just the GT_SIMD.
BlockRange().Remove(tree);
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.cs b/tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.cs
new file mode 100644
index 0000000000..00e0915fb1
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.cs
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Numerics;
+
+using Point = System.Numerics.Vector2;
+
+namespace GitHub_21854
+{
+ public class test
+ {
+ static int Main(string[] args)
+ {
+ try {
+ var unused = new object[] { Vector<int>.Zero };
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("FAILED with exception: " + e.Message);
+ return -1;
+ }
+ return 100;
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.csproj
new file mode 100644
index 0000000000..37a8837acd
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_21854/GitHub_21854.csproj
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{2649FAFE-07BF-4F93-8120-BA9A69285ABB}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>