Skip to content

Commit 58ecafb

Browse files
authored
JIT: Fix assertion failed 'genActualType(cmp->gtGetOp1()) == genActualType(cmp->gtGetOp2())' (#128959)
Fix #128947 This assert is not a function specific assumption, rather a general IR validation - to my understanding. The function uses the `supportedOp` lambda to actually cull out unsupported/uninteresting comparisons. So it should be fine to change it. The existing assert fired when seeing EQ(byref, long), for example: ```lua * NE int +--* LCL_VAR byref V01 arg1 \--* CAST long <- ulong <- uint \--* CNS_INT int 0 ``` Because it only considers `genActualType(cmp->gtGetOp1()) == genActualType(cmp->gtGetOp2())` legal. I don't really know what we consider legal IR and there is no centralized place so as a fix I copied this existing assert from importer: https://github.com/dotnet/runtime/blob/b0f76ec847aa48839262c4726554ea9e0f3bc4e6/src/coreclr/jit/importer.cpp#L7937-L7938
1 parent abb5453 commit 58ecafb

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/coreclr/jit/morph.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10957,13 +10957,14 @@ GenTree* Compiler::fgOptimizeBitwiseAnd(GenTreeOp* andOp)
1095710957
//
1095810958
GenTree* Compiler::fgOptimizeRelationalComparisonWithCasts(GenTreeOp* cmp)
1095910959
{
10960-
assert(cmp->OperIsCmpCompare());
10961-
assert(cmp->gtGetOp1()->OperIs(GT_CAST) || cmp->gtGetOp2()->OperIs(GT_CAST));
10962-
assert(genActualType(cmp->gtGetOp1()) == genActualType(cmp->gtGetOp2()));
10963-
1096410960
GenTree* op1 = cmp->gtGetOp1();
1096510961
GenTree* op2 = cmp->gtGetOp2();
1096610962

10963+
assert(cmp->OperIsCmpCompare());
10964+
assert(op1->OperIs(GT_CAST) || op2->OperIs(GT_CAST));
10965+
assert((genActualType(op1) == genActualType(op2)) || (varTypeIsI(op1) && varTypeIsI(op2)) ||
10966+
(varTypeIsFloating(op1) && varTypeIsFloating(op2)));
10967+
1096710968
if (!op1->TypeIs(TYP_LONG))
1096810969
{
1096910970
return cmp;

0 commit comments

Comments
 (0)