const bool requiresAdjustment = add;
const bool requiresDividendMultiuse = requiresAdjustment || !isDiv;
const unsigned curBBWeight = m_block->getBBWeight(comp);
- unsigned dividendLclNum = BAD_VAR_NUM;
if (requiresDividendMultiuse)
{
LIR::Use dividendUse(BlockRange(), &divMod->gtOp1, divMod);
- dividendLclNum = ReplaceWithLclVar(dividendUse);
- dividend = divMod->gtGetOp1();
+ dividend = ReplaceWithLclVar(dividendUse);
}
// Insert a new GT_MULHI node before the existing GT_UDIV/GT_UMOD node.
if (requiresAdjustment)
{
- GenTree* dividend = comp->gtNewLclvNode(dividendLclNum, type);
- GenTree* sub = comp->gtNewOperNode(GT_SUB, type, dividend, mulhi);
+ dividend = comp->gtNewLclvNode(dividend->AsLclVar()->GetLclNum(), dividend->TypeGet());
+ GenTree* sub = comp->gtNewOperNode(GT_SUB, type, dividend, mulhi);
BlockRange().InsertBefore(divMod, dividend, sub);
GenTree* one = comp->gtNewIconNode(1, TYP_INT);
BlockRange().InsertBefore(divMod, one, rsz);
LIR::Use mulhiUse(BlockRange(), &sub->gtOp.gtOp2, sub);
- unsigned mulhiLclNum = ReplaceWithLclVar(mulhiUse);
+ mulhi = ReplaceWithLclVar(mulhiUse);
- GenTree* mulhiCopy = comp->gtNewLclvNode(mulhiLclNum, type);
- GenTree* add = comp->gtNewOperNode(GT_ADD, type, rsz, mulhiCopy);
- BlockRange().InsertBefore(divMod, mulhiCopy, add);
+ mulhi = comp->gtNewLclvNode(mulhi->AsLclVar()->GetLclNum(), mulhi->TypeGet());
+ GenTree* add = comp->gtNewOperNode(GT_ADD, type, rsz, mulhi);
+ BlockRange().InsertBefore(divMod, mulhi, add);
mulhi = add;
shift -= 1;
GenTree* div = comp->gtNewOperNode(GT_RSZ, type, mulhi, shiftBy);
// divisor UMOD dividend = dividend SUB (div MUL divisor)
- GenTree* divisor = comp->gtNewIconNode(divisorValue, type);
- GenTree* mul = comp->gtNewOperNode(GT_MUL, type, div, divisor);
- GenTree* dividend = comp->gtNewLclvNode(dividendLclNum, type);
+ GenTree* divisor = comp->gtNewIconNode(divisorValue, type);
+ GenTree* mul = comp->gtNewOperNode(GT_MUL, type, div, divisor);
+ dividend = comp->gtNewLclvNode(dividend->AsLclVar()->GetLclNum(), dividend->TypeGet());
divMod->SetOper(GT_SUB);
divMod->gtOp1 = dividend;
bool requiresShiftAdjust = shift != 0;
bool requiresDividendMultiuse = requiresAddSubAdjust || !isDiv;
unsigned curBBWeight = comp->compCurBB->getBBWeight(comp);
- unsigned dividendLclNum = BAD_VAR_NUM;
if (requiresDividendMultiuse)
{
LIR::Use dividendUse(BlockRange(), &mulhi->gtOp.gtOp2, mulhi);
- dividendLclNum = ReplaceWithLclVar(dividendUse);
+ dividend = ReplaceWithLclVar(dividendUse);
}
GenTree* adjusted;
if (requiresAddSubAdjust)
{
- dividend = comp->gtNewLclvNode(dividendLclNum, type);
+ dividend = comp->gtNewLclvNode(dividend->AsLclVar()->GetLclNum(), dividend->TypeGet());
adjusted = comp->gtNewOperNode(divisorValue > 0 ? GT_ADD : GT_SUB, type, mulhi, dividend);
BlockRange().InsertBefore(divMod, dividend, adjusted);
}
BlockRange().InsertBefore(divMod, shiftBy, signBit);
LIR::Use adjustedUse(BlockRange(), &signBit->gtOp.gtOp1, signBit);
- unsigned adjustedLclNum = ReplaceWithLclVar(adjustedUse);
- adjusted = comp->gtNewLclvNode(adjustedLclNum, type);
+ adjusted = ReplaceWithLclVar(adjustedUse);
+ adjusted = comp->gtNewLclvNode(adjusted->AsLclVar()->GetLclNum(), adjusted->TypeGet());
BlockRange().InsertBefore(divMod, adjusted);
if (requiresShiftAdjust)
{
GenTree* div = comp->gtNewOperNode(GT_ADD, type, adjusted, signBit);
- dividend = comp->gtNewLclvNode(dividendLclNum, type);
+ dividend = comp->gtNewLclvNode(dividend->AsLclVar()->GetLclNum(), dividend->TypeGet());
// divisor % dividend = dividend - divisor x div
GenTree* divisor = comp->gtNewIconNode(divisorValue, type);
unsigned curBBWeight = comp->compCurBB->getBBWeight(comp);
LIR::Use opDividend(BlockRange(), &divMod->gtOp.gtOp1, divMod);
- ReplaceWithLclVar(opDividend);
-
- dividend = divMod->gtGetOp1();
- assert(dividend->OperGet() == GT_LCL_VAR);
-
- unsigned dividendLclNum = dividend->gtLclVar.gtLclNum;
+ dividend = ReplaceWithLclVar(opDividend);
GenTree* adjustment = comp->gtNewOperNode(GT_RSH, type, dividend, comp->gtNewIconNode(type == TYP_INT ? 31 : 63));
}
GenTree* adjustedDividend =
- comp->gtNewOperNode(GT_ADD, type, adjustment, comp->gtNewLclvNode(dividendLclNum, type));
+ comp->gtNewOperNode(GT_ADD, type, adjustment,
+ comp->gtNewLclvNode(dividend->AsLclVar()->GetLclNum(), dividend->TypeGet()));
GenTree* newDivMod;
// which simply discards the low log2(divisor) bits, that's just dividend & ~(divisor - 1)
divisor->gtIntCon.SetIconValue(~(absDivisorValue - 1));
- newDivMod = comp->gtNewOperNode(GT_SUB, type, comp->gtNewLclvNode(dividendLclNum, type),
+ newDivMod = comp->gtNewOperNode(GT_SUB, type,
+ comp->gtNewLclvNode(dividend->AsLclVar()->GetLclNum(), dividend->TypeGet()),
comp->gtNewOperNode(GT_AND, type, adjustedDividend, divisor));
}
--- /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>
+ <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>
\ No newline at end of file