Skip to content

Commit

Permalink
Normalize GT_UN(op, 0) early in importer
Browse files Browse the repository at this point in the history
Normalizing this idiom helps downstream optimizations.
  • Loading branch information
SingleAccretion committed Jun 22, 2021
1 parent 6f598f0 commit d2dd580
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13064,6 +13064,14 @@ void Compiler::impImportBlockCode(BasicBlock* block)
op2 = impPopStack().val;
op1 = impPopStack().val;

// Recognize the IL idiom of CGT_UN(op1, 0) and normalize
// it so that downstream optimizations don't have to.
if ((opcode == CEE_CGT_UN) && op2->IsIntegralConst(0))
{
oper = GT_NE;
uns = false;
}

#ifdef TARGET_64BIT
// TODO-Casts: create a helper that upcasts int32 -> native int when necessary.
// See also identical code in impGetByRefResultType and STSFLD import.
Expand All @@ -13085,7 +13093,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
op1 = gtNewOperNode(oper, TYP_INT, op1, op2);

// TODO: setting both flags when only one is appropriate.
if (opcode == CEE_CGT_UN || opcode == CEE_CLT_UN)
if (uns)
{
op1->gtFlags |= GTF_RELOP_NAN_UN | GTF_UNSIGNED;
}
Expand Down

0 comments on commit d2dd580

Please sign in to comment.