Skip to content

Commit

Permalink
JIT: A small CQ improvement for Equals/StartsWith unrolling (#76439)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed Oct 2, 2022
1 parent ca6fb31 commit 044caf6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ bool IntegralRange::Contains(int64_t value) const
}
break;

case GT_CNS_INT:
if (node->IsIntegralConst(0) || node->IsIntegralConst(1))
{
return {SymbolicIntegerValue::Zero, SymbolicIntegerValue::One};
}
break;

case GT_QMARK:
return Union(ForNode(node->AsQmark()->ThenNode(), compiler),
ForNode(node->AsQmark()->ElseNode(), compiler));

case GT_CAST:
return ForCastOutput(node->AsCast());

Expand Down Expand Up @@ -430,6 +441,12 @@ bool IntegralRange::Contains(int64_t value) const
return {lowerBound, upperBound};
}

/* static */ IntegralRange IntegralRange::Union(IntegralRange range1, IntegralRange range2)
{
return IntegralRange(min(range1.GetLowerBound(), range2.GetLowerBound()),
max(range1.GetUpperBound(), range2.GetUpperBound()));
}

#ifdef DEBUG
/* static */ void IntegralRange::Print(IntegralRange range)
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@ class IntegralRange
static IntegralRange ForNode(GenTree* node, Compiler* compiler);
static IntegralRange ForCastInput(GenTreeCast* cast);
static IntegralRange ForCastOutput(GenTreeCast* cast);
static IntegralRange Union(IntegralRange range1, IntegralRange range2);

#ifdef DEBUG
static void Print(IntegralRange range);
Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -5707,6 +5707,16 @@ struct GenTreeQmark : public GenTreeOp
assert((colon != nullptr) && colon->OperIs(GT_COLON));
}

GenTree* ThenNode()
{
return gtOp2->AsColon()->ThenNode();
}

GenTree* ElseNode()
{
return gtOp2->AsColon()->ElseNode();
}

#if DEBUGGABLE_GENTREE
GenTreeQmark() : GenTreeOp()
{
Expand Down

0 comments on commit 044caf6

Please sign in to comment.