RangeCheck: Don't create invalid ranges#113935
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
/azp list |
This comment was marked as resolved.
This comment was marked as resolved.
|
/azp run runtime-coreclr outerloop, runtime-coreclr jitstress, runtime-coreclr pgo, runtime-coreclr libraries-pgo, runtime-coreclr pgostress |
|
Azure Pipelines successfully started running 5 pipeline(s). |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
|
@dotnet/jit-contrib @amanasifkhalid PTAL In theory, invalid ranges are fine to have e.g.: and we still may extract useful info from that, but looks like many existing Range operations do not expect them so it's safer to just give up on them. They used to be not a problem when we used Range only for bounds checks, but we now use it for actual transformations in AssertProp as well. |
|
Were we expecting regressions? e.g. linux arm64 seeing +1.22% in |
Are we currently dead code eliminating these cases? |
|
@EgorBo have you had a chance to look at the insertion sort regression? |
|
Sorry for the delayed response.
RangeCheck uses a powerful and slow "Assertions + SSA-based analysis" mechanism and we don't use the same thing to fold unreachable branches. We re-use a limited form of it in the Global Assertion prop, but we don't use SSA-based analysis there because it's too slow (adds >1% TP regression), we only use assertions.
I've looked at those and while they look unfortunate (just a few functions), JIT had no right to optimize them based on what it analyzed: https://www.diffchecker.com/53WlCbZL/ This is just too complex flow for current jit's BCE to properly analyze it. Given that this PR unlocks @amanasifkhalid PR and fixes access violation in #116571 I think we should just accept it. I might still allow these functions to report "invalid" ranges like this, but at the moment I think various RangeOps:: simply don't expect them and produce invalid results. Also, for e.g. |
amanasifkhalid
left a comment
There was a problem hiding this comment.
LGTM. CI is in pretty rough shape, so we might want to wait for the next run before merging. Thanks!
Fixes a bug @amanasifkhalid hit in #113709
It is possible to create ranges where their lower limit is greater than the upper in
MergeEdgeAssertions. E.g.Some of our range operations (
RangeOps::Mergespecifically) do invalid operations on such ranges, so instead of fixing such places, I propose we don't create them in the first place (give up on them).Normally, this should not cause issues as such array accesses likely will never be accessible anyway, but we now use range analysis in assertprop