Skip to content

Commit

Permalink
Fix for division by zero (dotnet#75413)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiFoD committed Jan 14, 2023
1 parent 3708cd3 commit 3ed0ac5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11062,10 +11062,13 @@ GenTree* Compiler::fgOptimizeDivision(GenTreeOp* div)
// of root and child values
if (op1->OperIs(GT_UDIV, GT_DIV) && op2->IsIntegralConst() && op1->gtGetOp2()->IsIntegralConst())
{

GenTree* chOp1 = op1->gtGetOp1();
GenTree* chOp2 = op1->gtGetOp2();

// If there is a division by zero
if (chOp2->IsIntegralConst(0))
return nullptr;

IntegralRange boundRange = IntegralRange::ForNode(op2, this);
int64_t upperBound = IntegralRange::SymbolicToRealValue(boundRange.GetUpperBound());

Expand Down

0 comments on commit 3ed0ac5

Please sign in to comment.