}
//------------------------------------------------------------------------------
-// optVNConstantPropOnTree: Retrieve the assertions on this local variable
+// GetAssertionDep: Retrieve the assertions on this local variable
//
// Arguments:
// lclNum - The local var id.
switch (vnStore->TypeOfVN(vnCns))
{
case TYP_FLOAT:
- newTree = optPrepareTreeForReplacement(tree, tree);
- tree->ChangeOperConst(GT_CNS_DBL);
- tree->gtDblCon.gtDconVal = vnStore->ConstantValue<float>(vnCns);
- tree->gtVNPair = ValueNumPair(vnLib, vnCns);
- break;
+ {
+ float value = vnStore->ConstantValue<float>(vnCns);
+
+ if (tree->TypeGet() == TYP_INT)
+ {
+ // Same sized reinterpretation of bits to integer
+ newTree = optPrepareTreeForReplacement(tree, tree);
+ tree->ChangeOperConst(GT_CNS_INT);
+ tree->gtIntCon.gtIconVal = *(reinterpret_cast<int*>(&value));
+ tree->gtVNPair = ValueNumPair(vnLib, vnCns);
+ }
+ else
+ {
+ // Implicit assignment conversion to float or double
+ assert(varTypeIsFloating(tree->TypeGet()));
+
+ newTree = optPrepareTreeForReplacement(tree, tree);
+ tree->ChangeOperConst(GT_CNS_DBL);
+ tree->gtDblCon.gtDconVal = value;
+ tree->gtVNPair = ValueNumPair(vnLib, vnCns);
+ }
+ break;
+ }
case TYP_DOUBLE:
- newTree = optPrepareTreeForReplacement(tree, tree);
- tree->ChangeOperConst(GT_CNS_DBL);
- tree->gtDblCon.gtDconVal = vnStore->ConstantValue<double>(vnCns);
- tree->gtVNPair = ValueNumPair(vnLib, vnCns);
- break;
+ {
+ double value = vnStore->ConstantValue<double>(vnCns);
+
+ if (tree->TypeGet() == TYP_LONG)
+ {
+ // Same sized reinterpretation of bits to long
+ newTree = optPrepareTreeForReplacement(tree, tree);
+ tree->ChangeOperConst(GT_CNS_NATIVELONG);
+ tree->gtIntConCommon.SetLngValue(*(reinterpret_cast<INT64*>(&value)));
+ tree->gtVNPair = ValueNumPair(vnLib, vnCns);
+ }
+ else
+ {
+ // Implicit assignment conversion to float or double
+ assert(varTypeIsFloating(tree->TypeGet()));
+
+ newTree = optPrepareTreeForReplacement(tree, tree);
+ tree->ChangeOperConst(GT_CNS_DBL);
+ tree->gtDblCon.gtDconVal = value;
+ tree->gtVNPair = ValueNumPair(vnLib, vnCns);
+ }
+ break;
+ }
case TYP_LONG:
{
switch (tree->TypeGet())
{
case TYP_INT:
+ // Implicit assignment conversion to smaller integer
newTree = optPrepareTreeForReplacement(tree, tree);
tree->ChangeOperConst(GT_CNS_INT);
tree->gtIntCon.gtIconVal = (int) value;
break;
case TYP_LONG:
+ // Same type no conversion required
newTree = optPrepareTreeForReplacement(tree, tree);
tree->ChangeOperConst(GT_CNS_NATIVELONG);
tree->gtIntConCommon.SetLngValue(value);
break;
case TYP_FLOAT:
- newTree = optPrepareTreeForReplacement(tree, tree);
- tree->ChangeOperConst(GT_CNS_DBL);
- tree->gtDblCon.gtDconVal = (float) value;
- tree->gtVNPair = ValueNumPair(vnLib, vnCns);
+ // No implicit conversions from long to float and value numbering will
+ // not propagate through memory reinterpretations of different size.
+ unreached();
break;
case TYP_DOUBLE:
+ // Same sized reinterpretation of bits to double
newTree = optPrepareTreeForReplacement(tree, tree);
tree->ChangeOperConst(GT_CNS_DBL);
- tree->gtDblCon.gtDconVal = (double) value;
+ tree->gtDblCon.gtDconVal = *(reinterpret_cast<double*>(&value));
tree->gtVNPair = ValueNumPair(vnLib, vnCns);
break;
{
case TYP_REF:
case TYP_INT:
+ // Same type no conversion required
newTree = optPrepareTreeForReplacement(tree, tree);
tree->ChangeOperConst(GT_CNS_INT);
tree->gtIntCon.gtIconVal = value;
break;
case TYP_LONG:
+ // Implicit assignment conversion to larger integer
newTree = optPrepareTreeForReplacement(tree, tree);
tree->ChangeOperConst(GT_CNS_NATIVELONG);
- tree->gtIntConCommon.SetLngValue((INT64) value);
+ tree->gtIntConCommon.SetLngValue(value);
tree->gtVNPair = ValueNumPair(vnLib, vnCns);
break;
case TYP_FLOAT:
+ // Same sized reinterpretation of bits to float
newTree = optPrepareTreeForReplacement(tree, tree);
tree->ChangeOperConst(GT_CNS_DBL);
- tree->gtDblCon.gtDconVal = (float) value;
+ tree->gtDblCon.gtDconVal = *(reinterpret_cast<float*>(&value));
tree->gtVNPair = ValueNumPair(vnLib, vnCns);
break;
case TYP_DOUBLE:
- newTree = optPrepareTreeForReplacement(tree, tree);
- tree->ChangeOperConst(GT_CNS_DBL);
- tree->gtDblCon.gtDconVal = (double) value;
- tree->gtVNPair = ValueNumPair(vnLib, vnCns);
+ // No implicit conversions from int to double and value numbering will
+ // not propagate through memory reinterpretations of different size.
+ unreached();
break;
-
+
default:
return nullptr;
}
--- /dev/null
+<?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>
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ </PropertyGroup>
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="DevDiv_216571.il" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="app.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+ </PropertyGroup>
+</Project>
\ No newline at end of file