@@ -4542,6 +4542,9 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
4542
4542
4543
4543
retNode = cnsNode;
4544
4544
4545
+ impSpillSideEffects(false, (unsigned)CHECK_SPILL_ALL DEBUGARG(
4546
+ "spill side effects before folding two consts"));
4547
+
4545
4548
impPopStack();
4546
4549
impPopStack();
4547
4550
DEBUG_DESTROY_NODE(otherNode);
@@ -4553,28 +4556,35 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
4553
4556
4554
4557
if (cnsNode->IsFloatNaN())
4555
4558
{
4559
+ impSpillSideEffects(false, (unsigned)CHECK_SPILL_ALL DEBUGARG(
4560
+ "spill side effects before propagating NaN"));
4561
+
4556
4562
// maxsd, maxss, minsd, and minss all return op2 if either is NaN
4557
4563
// we require NaN to be propagated so ensure the known NaN is op2
4564
+
4558
4565
impPopStack();
4559
4566
impPopStack();
4560
4567
DEBUG_DESTROY_NODE(otherNode);
4561
4568
4562
4569
retNode = cnsNode;
4563
4570
break;
4564
4571
}
4565
- else if (ni == NI_System_Math_Max)
4572
+
4573
+ if (ni == NI_System_Math_Max)
4566
4574
{
4567
4575
// maxsd, maxss return op2 if both inputs are 0 of either sign
4568
4576
// we require +0 to be greater than -0, so we can't handle if
4569
4577
// the known constant is +0. This is because if the unknown value
4570
4578
// is -0, we'd need the cns to be op2. But if the unknown value
4571
4579
// is NaN, we'd need the cns to be op1 instead.
4580
+
4572
4581
if (cnsNode->IsFloatPositiveZero())
4573
4582
{
4574
4583
break;
4575
4584
}
4576
4585
4577
4586
// Given the checks, op1 can safely be the cns and op2 the other node
4587
+
4578
4588
ni = (callType == TYP_DOUBLE) ? NI_SSE2_Max : NI_SSE_Max;
4579
4589
4580
4590
// one is constant and we know its something we can handle, so pop both peeked values
@@ -4591,12 +4601,14 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
4591
4601
// the known constant is -0. This is because if the unknown value
4592
4602
// is +0, we'd need the cns to be op2. But if the unknown value
4593
4603
// is NaN, we'd need the cns to be op1 instead.
4604
+
4594
4605
if (cnsNode->IsFloatNegativeZero())
4595
4606
{
4596
4607
break;
4597
4608
}
4598
4609
4599
4610
// Given the checks, op1 can safely be the cns and op2 the other node
4611
+
4600
4612
ni = (callType == TYP_DOUBLE) ? NI_SSE2_Min : NI_SSE_Min;
4601
4613
4602
4614
// one is constant and we know its something we can handle, so pop both peeked values
0 commit comments