@@ -637,22 +637,27 @@ void RangeCheck::MergeEdgeAssertions(GenTreeLclVarCommon* lcl, ASSERT_VALARG_TP
637
637
//
638
638
bool RangeCheck::TryGetRangeFromAssertions (Compiler* comp, ValueNum num, ASSERT_VALARG_TP assertions, Range* pRange)
639
639
{
640
- MergeEdgeAssertions (comp, num, num , assertions, pRange);
640
+ MergeEdgeAssertions (comp, num, ValueNumStore::NoVN , assertions, pRange, false );
641
641
return !pRange->LowerLimit ().IsUnknown () || !pRange->UpperLimit ().IsUnknown ();
642
642
}
643
643
644
644
// ------------------------------------------------------------------------
645
645
// MergeEdgeAssertions: Merge assertions on the edge flowing into the block about a variable
646
646
//
647
647
// Arguments:
648
- // comp - the compiler instance
649
- // normalLclVN - the value number to look for assertions for
650
- // preferredBoundVN - when this VN is set, it will be given preference over constant limits
651
- // assertions - the assertions to use
652
- // pRange - the range to tighten with assertions
648
+ // comp - the compiler instance
649
+ // normalLclVN - the value number to look for assertions for
650
+ // preferredBoundVN - when this VN is set, it will be given preference over constant limits
651
+ // assertions - the assertions to use
652
+ // pRange - the range to tighten with assertions
653
+ // canUseCheckedBounds - true if we can use checked bounds assertions (cache)
653
654
//
654
- void RangeCheck::MergeEdgeAssertions (
655
- Compiler* comp, ValueNum normalLclVN, ValueNum preferredBoundVN, ASSERT_VALARG_TP assertions, Range* pRange)
655
+ void RangeCheck::MergeEdgeAssertions (Compiler* comp,
656
+ ValueNum normalLclVN,
657
+ ValueNum preferredBoundVN,
658
+ ASSERT_VALARG_TP assertions,
659
+ Range* pRange,
660
+ bool canUseCheckedBounds)
656
661
{
657
662
Range assertedRange = Range (Limit (Limit::keUnknown));
658
663
if (BitVecOps::IsEmpty (comp->apTraits , assertions))
@@ -680,7 +685,7 @@ void RangeCheck::MergeEdgeAssertions(
680
685
bool isUnsigned = false ;
681
686
682
687
// Current assertion is of the form (i < len - cns) != 0
683
- if (curAssertion->IsCheckedBoundArithBound ())
688
+ if (canUseCheckedBounds && curAssertion->IsCheckedBoundArithBound ())
684
689
{
685
690
ValueNumStore::CompareCheckedBoundArithInfo info;
686
691
@@ -709,7 +714,7 @@ void RangeCheck::MergeEdgeAssertions(
709
714
cmpOper = (genTreeOps)info.cmpOper ;
710
715
}
711
716
// Current assertion is of the form (i < len) != 0
712
- else if (curAssertion->IsCheckedBoundBound ())
717
+ else if (canUseCheckedBounds && curAssertion->IsCheckedBoundBound ())
713
718
{
714
719
ValueNumStore::CompareCheckedBoundArithInfo info;
715
720
@@ -767,7 +772,7 @@ void RangeCheck::MergeEdgeAssertions(
767
772
int cnstLimit = (int )curAssertion->op2 .u1 .iconVal ;
768
773
assert (cnstLimit == comp->vnStore ->CoercedConstantValue <int >(curAssertion->op2 .vn ));
769
774
770
- if ((cnstLimit == 0 ) && (curAssertion->assertionKind == Compiler::OAK_NOT_EQUAL) &&
775
+ if ((cnstLimit == 0 ) && (curAssertion->assertionKind == Compiler::OAK_NOT_EQUAL) && canUseCheckedBounds &&
771
776
comp->vnStore ->IsVNCheckedBound (curAssertion->op1 .vn ))
772
777
{
773
778
// we have arr.Len != 0, so the length must be atleast one
0 commit comments