Skip to content

Commit c58b659

Browse files
authored
JIT: Fix check for cast type for cast on top of address (#118019)
1 parent e831ce8 commit c58b659

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/coreclr/jit/lclmorph.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,18 +1241,21 @@ class LocalAddressVisitor final : public GenTreeVisitor<LocalAddressVisitor>
12411241
break;
12421242

12431243
case GT_CAST:
1244+
{
12441245
assert(TopValue(1).Node() == node);
12451246
assert(TopValue(0).Node() == node->AsCast()->CastOp());
12461247

1247-
if (!node->TypeIs(TYP_I_IMPL, TYP_BYREF) || node->gtOverflow() || !TopValue(0).IsAddress() ||
1248+
var_types castToType = node->CastToType();
1249+
bool isPtrCast = (castToType == TYP_I_IMPL) || (castToType == TYP_U_IMPL) || (castToType == TYP_BYREF);
1250+
if (!isPtrCast || node->gtOverflow() || !TopValue(0).IsAddress() ||
12481251
!TopValue(1).AddOffset(TopValue(0), 0))
12491252
{
12501253
EscapeValue(TopValue(0), node);
12511254
}
12521255

12531256
PopValue();
12541257
break;
1255-
1258+
}
12561259
case GT_CALL:
12571260
while (TopValue(0).Node() != node)
12581261
{

0 commit comments

Comments
 (0)