Skip to content

Commit

Permalink
Naive fix for dotnet#57535
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Aug 17, 2021
1 parent 885e7a2 commit cde5dd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6607,6 +6607,8 @@ class Compiler
BasicBlock* exit,
unsigned char exitCnt);

bool optNarrowTree(GenTree* tree, var_types srct, var_types dstt, ValueNumPair vnpNarrow, bool doit);

protected:
unsigned optCallCount; // number of calls made in the method
unsigned optIndirectCallCount; // number of virtual, interface and indirect calls made in the method
Expand Down Expand Up @@ -6736,8 +6738,6 @@ class Compiler

int optIsSetAssgLoop(unsigned lnum, ALLVARSET_VALARG_TP vars, varRefKinds inds = VR_NONE);

bool optNarrowTree(GenTree* tree, var_types srct, var_types dstt, ValueNumPair vnpNarrow, bool doit);

/**************************************************************************
* Optimization conditions
*************************************************************************/
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/jit/loopcloning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,18 @@ GenTree* LC_Condition::ToGenTree(Compiler* comp, BasicBlock* bb)
{
GenTree* op1Tree = op1.ToGenTree(comp, bb);
GenTree* op2Tree = op2.ToGenTree(comp, bb);
unsigned op1Size = genTypeSize(genActualType(op1Tree));
unsigned op2Size = genTypeSize(genActualType(op2Tree));

if (op1Size < op2Size)
{
comp->optNarrowTree(op2Tree, op2Tree->TypeGet(), op1Tree->TypeGet(), op2Tree->gtVNPair, true);
}
else if (op1Size > op2Size)
{
comp->optNarrowTree(op1Tree, op1Tree->TypeGet(), op2Tree->TypeGet(), op1Tree->gtVNPair, true);
}

assert(genTypeSize(genActualType(op1Tree->TypeGet())) == genTypeSize(genActualType(op2Tree->TypeGet())));
return comp->gtNewOperNode(oper, TYP_INT, op1Tree, op2Tree);
}
Expand Down

0 comments on commit cde5dd5

Please sign in to comment.