Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,21 +289,58 @@ static Range GetRange(Compiler* comp, GenTree* tree, BasicBlock* block, ASSERT_V
}

int64_t constValue = node->AsIntConCommon()->IntegralValue();

if (FitsIn<int32_t>(constValue))
if (constValue < 0)
{
rangeType = TYP_INT;
// We don't try and reason about lower bounds here to simplify the logic.
break;
Comment on lines +292 to +295

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will word this better.

}
else if (FitsIn<uint32_t>(constValue))

// For a non-negative constant, try and find a tighter upper bound
if (constValue <= UINT16_MAX)
{
rangeType = TYP_UINT;
if (constValue <= UINT8_MAX)
Comment thread
adamperlin marked this conversation as resolved.
{
if (constValue <= INT8_MAX)
{
rangeType = TYP_BYTE;
}
else
{
rangeType = TYP_UBYTE;
}
}
else
{
if (constValue <= INT16_MAX)
{
rangeType = TYP_SHORT;
}
else
{
rangeType = TYP_USHORT;
}
}
}

if (constValue >= 0)
else
{
return {SymbolicIntegerValue::Zero, UpperBoundForType(rangeType)};
if (constValue <= UINT32_MAX)
{
if (constValue <= INT32_MAX)
{
rangeType = TYP_INT;
}
else
{
rangeType = TYP_UINT;
}
}
else
{
rangeType = TYP_LONG;
}
}
break;

return {SymbolicIntegerValue::Zero, UpperBoundForType(rangeType)};
}

case GT_QMARK:
Expand Down
Loading