Skip to content

Commit 953f308

Browse files
authored
Fix assert in IsKnownConstant importation (#118634)
1 parent da7900c commit 953f308

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/coreclr/jit/importercalls.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,14 +3651,14 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
36513651
if (op1->OperIsConst() || gtIsTypeof(op1))
36523652
{
36533653
// op1 is a known constant, replace with 'true'.
3654-
retNode = gtNewIconNode(1);
3654+
retNode = gtNewTrue();
36553655
JITDUMP("\nExpanding RuntimeHelpers.IsKnownConstant to true early\n");
36563656
// We can also consider FTN_ADDR here
36573657
}
36583658
else if (opts.OptimizationDisabled())
36593659
{
36603660
// It doesn't make sense to carry it as GT_INTRINSIC till Morph in Tier0
3661-
retNode = gtNewIconNode(0);
3661+
retNode = gtNewFalse();
36623662
JITDUMP("\nExpanding RuntimeHelpers.IsKnownConstant to false early\n");
36633663
}
36643664
else

src/coreclr/jit/morph.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8419,12 +8419,14 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
84198419
// We're lucky to catch a constant here while importer was not
84208420
JITDUMP("true\n");
84218421
DEBUG_DESTROY_NODE(tree, op1);
8422-
tree = gtNewIconNode(1);
8422+
tree = gtNewTrue();
84238423
}
84248424
else
84258425
{
84268426
JITDUMP("false\n");
8427-
tree = gtWrapWithSideEffects(gtNewIconNode(0), op1, GTF_ALL_EFFECT);
8427+
tree = gtNewFalse();
8428+
tree->SetMorphed(this);
8429+
tree = gtWrapWithSideEffects(tree, op1, GTF_ALL_EFFECT);
84288430
}
84298431
tree->SetMorphed(this);
84308432
return tree;

0 commit comments

Comments
 (0)